How to change the asset path in RubyOnRails
December 10, 2005
Tags: Dropbox Rails Ruby
If you don't want to name your asset directories for javascript files and stylesheets "javascripts" and "stylesheets" here is how you can change the default path settings.
Add the following snippet to your app/controllers/application.rb:
module ActionView
module Helpers
module AssetTagHelper
# Returns path to a javascript asset. Example:
#
# javascript_path "xmlhr" # => /javascripts/xmlhr.js
def javascript_path(source)
compute_public_path(source, 'js', 'js')
end
# Returns path to a stylesheet asset. Example:
#
# stylesheet_path "style" # => /stylesheets/style.css
def stylesheet_path(source)
compute_public_path(source, 'css', 'css')
end
end
end
end