sass-rails helpers “image-url”, “asset-url” are not working in rails 3.2.1

后端 未结 9 2093
一整个雨季
一整个雨季 2020-12-12 20:36

I am on 3.2.1, with sass-rails-3.2.4 and sass-3.1.15...

The documentation for the asset pipeline says:

asset-url(\"rails.png\", image) becomes url(/a         


        
相关标签:
9条回答
  • 2020-12-12 21:23

    We just had the same problem and fixed it by explicitly requiring sprockets in the Gemfile (even though it's a dependency of ActionPack):

    group :assets do
      gem 'sprockets'
      gem 'sass-rails', '~> 3.2.3'
      # ...
    end
    

    I don't know why, but it works now. ;-)

    0 讨论(0)
  • 2020-12-12 21:25

    You might want to try clearing /tmp/cache. I am too new to Rails and Sass to know why this worked, but it solved the same problem for me after hours of searching.

    BTW, this worked despite the fact that I could see other Sass directives, such as setting variables and calculating with them, being executed. I'm sure there is a very simple explanation, once I have time to track it down.

    0 讨论(0)
  • 2020-12-12 21:25

    You can just add a trailing forward slash / to the path and use url like you usually do.

    background-image: url("/assets/rails.png")
    
    0 讨论(0)
提交回复
热议问题