Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default stylesheet dir in rails

Would anyone know to change the default stylesheet directory /public/stylesheets to /public/css in rails 3?

I found a variable called config.stylesheets_dir = '/css'

This didn't work though.

I know I can do <%= stylesheet_link_tag '/css/mystyle.css' %> but I'm curious if there's a better way.

like image 972
bunwich Avatar asked Oct 13 '22 23:10

bunwich


1 Answers

Javascript and stylesheets paths were not fully dehardcoded in Rails 3. To override these paths you need to monkey patch (with all consequences of that) private method:

module ActionView::Helpers::AssetTagHelper
    private
      def compute_stylesheet_paths(*args)
          expand_stylesheet_sources(*args).collect { |source| compute_public_path(source, 'stylesheets', 'css', false) }
      end
end

and additionaly this one if you use it:

  def stylesheet_path(source)
    compute_public_path(source, 'stylesheets', 'css')
  end
like image 137
gertas Avatar answered Oct 16 '22 15:10

gertas