Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant Haml::Filters::SassImporter #77

Open
such opened this issue Jan 7, 2015 · 4 comments
Open

uninitialized constant Haml::Filters::SassImporter #77

such opened this issue Jan 7, 2015 · 4 comments

Comments

@such
Copy link

such commented Jan 7, 2015

Hello,
I've stumbled across this issue when upgrading my app to Rails 4.2.

It can be reproduced with a new rails project.

  • add following gem dependencies:
gem 'haml-rails', '~> 0.5.3'
gem 'compass-rails', '~> 2.0.3'
  • rename application.css in application.css.scss and add @import 'compass';
  • add the following config in application.rb:
    config.assets.enabled = true (important part!)
  • generate a model, a controller and view. In the view add inline scss:
:scss
  h1 {
    color: yellow;
  }

When trying to access the view, the following error will be raised:

ActionView::Template::Error (uninitialized constant Haml::Filters::SassImporter):
  compass-rails (2.0.3) lib/compass-rails/patches/sass_importer.rb:58:in `sass_importer_artiy'
  compass-rails (2.0.3) lib/compass-rails/patches/sass_importer.rb:63:in `sass_importer'
  compass-rails (2.0.3) lib/compass-rails/patches/sass_importer.rb:18:in `block in evaluate'
  compass-rails (2.0.3) lib/compass-rails/patches/sass_importer.rb:18:in `map'
  compass-rails (2.0.3) lib/compass-rails/patches/sass_importer.rb:18:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  haml (4.0.6) lib/haml/sass_rails_filter.rb:8:in `render'
  (eval):5:in `render_with_options'
  haml (4.0.6) lib/haml/filters.rb:184:in `block in compile'
  haml (4.0.6) lib/haml/filters.rb:162:in `instance_eval'
  haml (4.0.6) lib/haml/filters.rb:162:in `compile'
  haml (4.0.6) lib/haml/filters.rb:141:in `internal_compile'
  haml (4.0.6) lib/haml/compiler.rb:273:in `compile_filter'
  haml (4.0.6) lib/haml/compiler.rb:20:in `compile'
  haml (4.0.6) lib/haml/compiler.rb:22:in `block (2 levels) in compile'
  haml (4.0.6) lib/haml/compiler.rb:22:in `each'
  haml (4.0.6) lib/haml/compiler.rb:22:in `block in compile'
  haml (4.0.6) lib/haml/compiler.rb:95:in `compile_root'
  haml (4.0.6) lib/haml/compiler.rb:22:in `compile'
  haml (4.0.6) lib/haml/engine.rb:66:in `initialize'
  haml (4.0.6) lib/haml/template/plugin.rb:25:in `new'
  haml (4.0.6) lib/haml/template/plugin.rb:25:in `compile'
  haml (4.0.6) lib/haml/template/plugin.rb:30:in `call'

As a workaround, I prevented the load of sass_rails_filter by removing config.assets.enabled = true in application.rb (it's supposed to be by default now anyway). If I understand correctly it only prevents me from using rails helpers in inline sass.

As a sidenote, the test app.config.assets.enabled in haml-4.0.6/lib/haml/railtie.rb seems buggy since app.config.assets.enabled is nil for a new rails app even though asset pipeline is enabled by default...

Please tell me if you need any more information.
You might also consider that the issue belongs to compass-rails... Let me know!

@frahugo
Copy link

frahugo commented Jan 29, 2015

+1

I get the error in a view rendered by ActionMailer as well

@frahugo
Copy link

frahugo commented Jan 29, 2015

I downgraded sass-rails to 4.0.5 and compass-rails to '1.1.7' and it solved the problem on my side. Strange.

@frahugo
Copy link

frahugo commented Jan 29, 2015

Oh well, now I'm having this error Unsupported rails environment for compass in some of my tests. I would have to move back up to compass-rails v2.

Everything works fine now with the latest compass-rails (2.0.0) and an old sass-rails version: 4.0.5

@reidnimz
Copy link

I believe this is a bug compass-rails, as sass-rails changed out from underneath it. I'll try and get a solution in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants