/ / style.css.erb precompile assets gives undefined method `[]' for nil:NilClass error - ruby-on-rails-3.2, asset-pipeline

style.css.erb precompile assets надає невизначений метод `[] 'для nil: помилка NilClass - ruby-on-rails-3.2, конвеєр активів

I have created one file for the fonts in the stylesheets folder in rails application

@font-face {
font-family: "MuseoSans500";
src: url("<%= asset_path("museosans_500-webfont.eot?")%>") format("embedded-opentype");
font-weight: normal;
font-style: normal;
}

@font-face {
font-family: "MuseoSans500";
src: url("<%= asset_path("museosans_500-webfont.woff")%>") format("woff"),
url("<%= asset_path("museosans_500-webfont.ttf")%>") format("truetype"),
url("<%= asset_path("museosans_500-webfont.svg#MuseoSans500")%>") format("svg");
font-weight: normal;
font-style: normal;
}

Now When I precompile the assets .. It gives me error on the style.css.erb page. I have kept trace on the sprockets for the path and I got this file. The error is

paths  subpath /home/new_app/app/assets/stylesheets/app-theme/themes/default/style.css.erb
rake aborted!
undefined method `[]" for nil:NilClass

(in /home/hbror/applications/survey/app/assets/stylesheets/application.css)

Відповіді:

1 для відповіді № 1

You should place your fonts in a new asset directory, for example app/assets/fonts and include it in asset directories by placing this in your application.rb:

# Add the fonts path
config.assets.paths << Rails.root.join("app", "assets", "fonts")

# Precompile additional assets
config.assets.precompile += %w( .svg .eot .woff .ttf )

Then it should work fine.