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

3 thoughts on “Storing .js files and .css files in 'js' and 'css' directories in Rails 2.2”

  1. This really goes against the convention over configuration ideology of rails (which you already know), and imo – isn’t one worth toying with. May as well start playing with the naming conventions, because someone simply doesn’t like what it’s called. I’m in agreeance with you – I think css/js are much better directory names, but changing the application to match my own taste in naming is a waste of time.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.