Jamie Hill
Photo of Jamie Hill

UX Designer, CSS Wizard, Ruby on Rails Developer.

Storing .js files and .css files in 'js' and 'css' directories in Rails 2.2

In the years I have been working with Rails I have generally been happy to follow the conventions that it enforces. There is one that just doesn’t sit right with me and that is the decision to store .css files in a ‘stylesheets’ directory and .js files in a ‘javascripts’ directory as I prefer ‘css’ and ‘js’ directories (call me old fashioned).
Achieving this in Rails 2.2 involves changing a couple of constants. I may submit a patch with a config hook for this as it feels a little dirty changing the constants directly. Add the following lines to your environment.rb file.

ActionView::Helpers::AssetTagHelper::StylesheetAsset::DIRECTORY = 'css'.freeze
ActionView::Helpers::AssetTagHelper::JavaScriptAsset::DIRECTORY = 'js'.freeze