CSS and JS directories in Rails

One thing that annoyed me when I first started using Rails at 0.14 was that I was forced to put my .css files in a ’stylesheets’ directory and my .js files in a ‘javascripts’ directory.

Previous to Rails I would put .css files in a ‘css’ directory and .js files in a ‘js’ directory (call me old fashioned). I use the following code in my application helper to allow me to do this:

module ApplicationHelper
  def javascript_path(source) compute_public_path(source, 'js', 'js') end
  def stylesheet_path(source) compute_public_path(source, 'css', 'css') end
end

Just incase anyone else has the same niggle.

Update 29-11-08: for Rails 2.2, see new post.

Tags: , ,

1 comment so far ↓

#1 Branstrom on 10.04.06 at 4:18 pm

That’s great, I’ve been using short folder names too, as long as I can remember.

Leave a Comment