Search code examples
ruby-on-rails-3herokustylesheetsasscompass-sass

how to include stylesheet in root folder of rails 3


Due to some heroku problems with rails 3 and compass framework, we followed this guide:

http://lds.li/post/673242899/compass-with-rails-3-on-heroku

and moved our stylesheets to app_name/tmp/stylesheets.

I tried using

stylesheet_link_tag "#{Rails.root}/tmp/stylesheets/main.css"

but that doesnt work as it looks for the css file in

http://localhost:3000/app_name/tmp/stylesheets/main.css

I know this is a simple fix and I'm overlooking something simple but hopefully someone can answer this with one look. Thanks in advance!

I would like to point out that we have this in our stylesheets.rb

Rails.configuration.middleware.insert_before('Rack::Sendfile', 'Rack::Static',
                                         :urls => ['/stylesheets/compiled'],
                                         :root => "#{Rails.root}/tmp")

WHen I try "compass watch" it still compiles to "tmp/stylesheets/main.css" instead of stylesheets/compiled.


Solution

  • I personally take a different approach to solving this problem:

    Stick the following code in your compass initializer:

    Sass::Plugin.options[:never_update] = true
    

    This prevents sass from trying to write to your filesystem when the server is hit.

    Just make sure that you are running compass watch in development mode and commit the compiled stylesheets to yout git repo

    This saves so much time - if you don't like this approach, try hassle or one of the recent forks