문제

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.

도움이 되었습니까?

해결책

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

다른 팁

Change your config/compass.rb to set css_dir = "tmp/stylesheets/compiled"

Based on what you have in your configuration, you should be using this for your template:

stylesheet_link_tag "compiled/main.css"

(Which renders <link rel="/stylesheets/compiled/main.css" ...)

(The tmp dir is outside of public; it shouldn't appear in the URLs because the middleware is taking care of remapping it.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top