Sass import error in Rails 3 app - “File to import not found or unreadable: compass”

后端 未结 7 1251
梦如初夏
梦如初夏 2020-12-03 07:23

I have a Rails 3 app on which I successfully ran compass init rails ./ --using blueprint. I can @import files from the /stylesheets directory, but

相关标签:
7条回答
  • 2020-12-03 07:41

    Okay, after help from the amazing Chris Eppstein I was able to find the offending line. In config/environments.rb I had this line:

    Sass::Plugin.options[:template_location] = {
    "#{RAILS_ROOT}/app/stylesheets" => "#{RAILS_ROOT}/public/stylesheets"
    }
    

    With the currently versions of Rails (I have 3.0.7) and Compass (0.11.1) this line is not necessary. I added it after following a tutorial. If sass can't find compass, it might be because this line is messing up your Sass::Plugin.options[:template_location].

    0 讨论(0)
  • 2020-12-03 07:42

    I fixed this problem by switching to the compass-rails gem instead of the compass gem in my Gemfile (don't forget to reboot your server). Just in case someone might come across here.

    0 讨论(0)
  • 2020-12-03 07:42

    I fixed this error like this:

    In application.rb I had

    Bundler.require(:default, Rails.env) if defined?(Bundler)  
    

    and changed to

    Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)
    

    This was after updating a project from 3.0.3 to 3.2.13

    0 讨论(0)
  • 2020-12-03 07:43

    I was getting this error.

    I changed this line in my application.rb from:

    Bundler.require(:default, Rails.env) if defined?(Bundler)
    

    to:

    Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)
    

    Also, make sure the files are names something.css.sass NOT something.sass

    And one other thing, I had an old compass.rb file in my config directory which isn't needed in Rails 3.2. Deleting that also solved this problem for me.

    0 讨论(0)
  • 2020-12-03 07:49

    I fixed this problem on my Rails 3.2.0 server by moving out gem 'compass-rails', '~> 1.0.1' from the :assets group in the Gemfile, from a tip in https://github.com/Compass/compass-rails/issues/19.

    0 讨论(0)
  • 2020-12-03 07:53

    I fixed this error after banging my head over it

    I commented this line in my application.rb from:

    Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)
    

    and uncommented:

    Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)    
    

    I am using Rails 3.2.11

    0 讨论(0)
提交回复
热议问题