Add a new asset path in Rails 3.1 Add a new asset path in Rails 3.1 ruby-on-rails ruby-on-rails

Add a new asset path in Rails 3.1


Andrew, app/assets/fonts is actually already in your asset load path, along with images. So you can just point to the asset in the same way: <%= asset_path('/Ubuntu/Ubuntu-R-webfont.eot') %>[1] or how ever you are referencing your images.

It took me a while to wrap my head around this as well. I still don't know what happens if there's a file with the same name in app/assets/fonts and app/assets/images.

[1] Assuming you have a font at app/assets/fonts/Ubuntu/Ubuntu-R-webfont.eot


Andrew, Jason, agreed. FWIW I put this in my config/application.rb next to

  # Enable the asset pipelineconfig.assets.enabled = trueconfig.assets.paths << "#{Rails.root}/app/assets/fonts"


By creating app/assets/images and app/assets/fonts they will be automatically added to the assets path.

Open up rails console after creating them and check with:

y Rails.application.config.assets.paths 

(y is a shortcut for the yaml method)