Comments (59)
Reproduction instructions (with latest rails 3-1-stable):
rails generate controller Say hello goodbye
Full scenario and captured output: http://intertwingly.net/projects/AWDwR4/checkdepot-192-31/section-2.html
from sass-rails.
git bisect output:
1edfadf82e992c98de53eaef4bde02fa4f47ec5e is the first bad commit
commit 1edfadf82e992c98de53eaef4bde02fa4f47ec5e
Date: Wed Jul 27 15:09:42 2011 -0500
Make Rails.application.assets available in initializers
Note: markdown is being too helpful here. Correct link for the commit is as follows:
from sass-rails.
Should be able to move that monkey patch into the railtie initializer:
initializer :setup_sass do |app|
# ...
app.assets.context_class.extend(Sass::Rails::SassContext)
app.assets.context_class.sass_config = app.config.sass
end
from sass-rails.
same issue here with rails-3-1-stable & sass-rails-3.1.0.rc.5
from sass-rails.
I can verify that the following works on rails master:
module Sass::Rails::SassContext
attr_accessor :sass_config
end
begin
# Before sprockets was extracted from rails
require 'sprockets/railtie'
module Sprockets
class Railtie < ::Rails::Railtie
initializer :setup_sass do |app|
app.assets.context_class.extend(Sass::Rails::SassContext)
app.assets.context_class.sass_config = app.config.sass
end
end
end
rescue LoadError
# After sprockets was extracted into sprockets-rails
require 'sprockets/rails/railtie'
module Sprockets
module Rails
class Railtie < ::Rails::Railtie
include Sass::Rails::SprocketsConfig
end
end
end
end
Note that I only added the code that Josh provided to the Before sprockets was extracted from rails code path as that is the path used with the Rails master.
from sass-rails.
I've now verified that the same code works with 3-1-stable. As sass-rails versions are tightly coupled with Rails versions, I suggest that the rescue LoadError
is not needed?
from sass-rails.
sass-rails can add a requirement for rails ~> 3.1.0.rc5
and remove any old hacks.
from sass-rails.
Some new commits on https://github.com/rails/sass-rails/commits/3-1-stable please let me know if there's any other issue so I can release.
from sass-rails.
Fixed the one in the issue, but created another one:
undefined method `context_class' for nil:NilClass
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/activesupport/lib/active_support/whiny_nil.rb:48:in `method_missing'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/sass-rails-c0ff27f44c4a/lib/sass/rails/railtie.rb:40:in `block in <class:Railtie>'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/initializable.rb:25:in `instance_exec'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/initializable.rb:25:in `run'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/initializable.rb:50:in `block in run_initializers'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/initializable.rb:49:in `each'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/initializable.rb:49:in `run_initializers'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/application.rb:92:in `initialize!'
/Users/gk/.rvm/gems/ruby-1.9.2-p180-patched/bundler/gems/rails-ac24a53ffc02/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/gk/Work/Projects/gastro/config/environment.rb:8:in `<top (required)>'
from sass-rails.
grrr. can someone see if they can fix this? I'm at work now.
from sass-rails.
Wow, github really surprised me with referencing this.
from sass-rails.
@grk can you provide a failing test case with it?
from sass-rails.
8 specs fail without it.
from sass-rails.
I've tested @chriseppstein changes on both 3-1-stable and master, and they work for me.
I've tried @grk's version, and oddly my test is failing once I turn on:
config.action_controller.perform_caching = true
I'm going to try further tests to verify that this was caused by grk's changes and is not unrelated.
from sass-rails.
That fix doesn't do anything. Its as good as commenting out that code.
from sass-rails.
@grk commit is wrong, @rubys can you test it now? I've reverted it
from sass-rails.
from sass-rails.
assuming this fixes the problem, can you add it to the 3-1-stable branch?
from sass-rails.
are you testing in both production and development modes? My assumption is yes but my trivial app runs in production but not in development with this mornings code.
from sass-rails.
I'm still getting undefined method 'context_class'
like @grk got previously. Using rails 3-1-stable and sass-rails 3-1-stable.
/Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/activesupport/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `context_class' for nil:NilClass (NoMethodError)
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/sass-rails-ad73d00ea9f2/lib/sass/rails/railtie.rb:40:in `block in <class:Railtie>'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/initializable.rb:25:in `run'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/initializable.rb:49:in `each'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/application.rb:92:in `initialize!'
from /Users/johnny/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-f2ade6f4b0d3/railties/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/johnny/test/config/environment.rb:5:in `<top (required)>'
from sass-rails.
@josh's commit fixes it but it's not part of the 3-1-stable branch yet...
from sass-rails.
Ah, yes. I somehow kept thinking that 3-1-stable was the working branch. But you're right, that require
fixes the problem.
from sass-rails.
Pushed to 3-1-stable
from sass-rails.
I'm still getting undefined method 'context_class'
errors when running the tests in the 3-1-stable branch. This is with all the gems as per Gemfile.lock, running bundle exec rake test
.
from sass-rails.
@huerlisi steps to reproduce it? did you run bundle update before? just checking because shouldn't be an issue anymore.
from sass-rails.
@spastorino did not run bundle update
but bundle
which should use the gems per Gemfile.lock
AFAIK. Will try with bundle update
right now.
This is with ruby 1.8.7
from sass-rails.
Same after a bundle update
. Gemfile.lock
was not modified, looks like using same gem/git versions as the one who checked in.
See log of commands and output at https://gist.github.com/1122050
from sass-rails.
@huerlisi It's working perfect for me but the way I'm able to test sass-rails it's odd.
I have cloned sprockets and sass and done this https://gist.github.com/93866fc6403d40d67d0d
Results of the tests for me ...
➜ sass-rails git:(3-1-stable) ✗ bundle exec rake test
Loaded suite /Users/santiago/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
..............
Finished in 55.896585 seconds.
14 tests, 34 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 63056
Can you try doing the same?
/cc @chriseppstein it's there a better way to test sass-rails? just cloning sass-rails and running the tests I get the same results @huerlisi is getting
from sass-rails.
@spastorino What rails/sprocket branches have you checked out?
AFAIK the sass-rails 3-1-stable branch should work with rails 3.1. To actually test it against this version you need to have rails branch 3-1-stable or similar checked out.
from sass-rails.
why is this ticket marked as "closed" ?
I just ran into this issue by rebuilding my Gemfile.lock, thus, updating the branch heads of my 3.1 rails.
from sass-rails.
@huerlisi use 3-1-stable branch of Rails, and master of sprockets and sass
from sass-rails.
@trapni have you tested with the steps I've provided?, can you provide info on what's wrong?
from sass-rails.
Same issue here. "undefined method asset_environment for class Sprockets::Railtie'
I'm using:
gem 'rails', '3.1.0.rc5', :git => "git://github.com/rails/rails", :branch => "3-1-stable"
gem "sass-rails"
Adding 3-1stable branch to sass-rails fixes the error:
gem "sass-rails", git: 'https://github.com/rails/sass-rails.git', branch: '3-1-stable'
But now, I'm getting the same issue than @johnnym:
"`method_missing': undefined method `context_class' for nil:NilClass"
from sass-rails.
@mariozaizar, the gem setup below is working for me (aside from a new issue in compass/blueprint).
gem "rails", :git => 'https://github.com/rails/rails.git', :branch => '3-1-stable'
gem 'sass', '3.1.5'
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
group :assets do
gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git', :branch => '3-1-stable'
# others removed for simplicity
end
I forgot to mention... you should also gem uninstall sass -v3.1.6
from sass-rails.
@johnlauck, Thanks but that didn't work.. But, now I can confirm that doing the monkey patch from:
# https://github.com/rails/sass-rails/commit/8cf2d6072727c9e70ee54c767c9055e23e1594f5
app.config.assets.context_class.extend(SassContext)
app.config.assets.context_class.sass_config = app.config.sass
Totally works for "method_missing': undefined method context_class for nil:NilClass"
buuuut... Now I'm getting this: undefined method sass_config for #<Class:0x00000102028868>
from sass-rails.
I've fixed "
method_missing': undefined method context_class' for nil:NilClass"
by enabling asset pipeline (config.assets.enabled = true
) in my application.rb
.
Otherwise Sprockets::Railtie
bails out too early failing to set-up app.assets
(see https://github.com/rails/rails/blob/83d9398ec049e414ce57/actionpack/lib/sprockets/railtie.rb#L16) which leads to Sass::Rails::Railite
blowing up on app.assets
being nil
here: https://github.com/rails/sass-rails/blob/890273d7eebd2a1c6b28/lib/sass/rails/railtie.rb#L42.
from sass-rails.
@thedarkone, why is it that you've got sass-rails install but the asset-pipeline disabled... This seems like a strange use case to me.
from sass-rails.
I'm trying to upgrade sass and compass (to their current masters) in my 3.1 app, I'm not comfortable with asset-pipeline yet and I have compass's Railtie
blowing up because app.config.sass
is no set up. I thought that was what sass-rails
was for and then run into this weird error...
from sass-rails.
I see the same issue as @mariozaizar
In my case, it is caused by line 47 in template_handlers.rb, in the sass_options_from_rails method i.e.
scope.environment.context_class.sass_config
I do not understand enough about Rails internals to know why the context_class does not have a sass_config method since the one used in railtie.rb does.
It would appear that the context_class in railtie.rb can not the same one used in this method.
from sass-rails.
Hi guys,
This is the current Gemfile that I'm using, and seems to be working now (I'm not using the monkey patch anymore):
gem 'rails', '3.1.0.rc5', :git => "git://github.com/rails/rails", :branch => "3-1-stable"
gem "sass-rails", :git => 'https://github.com/rails/sass-rails.git', :branch => '3-1-stable'
gem 'compass', :git => 'https://github.com/chriseppstein/compass.git', :branch => 'rails31'
gem 'haml', :git => "git://github.com/cheald/haml.git"
gem "haml-rails"
Cheers!
from sass-rails.
Mario,
Thanks for posting that.
I changes my Gemfile from
gem 'rails', '3.1.0.rc5'
to use rc5 from github exactly as you do.
And the problem went away.
Which suggests there must be some difference between the "regular" gem and github?
from sass-rails.
How can I get this working with gem 'rails', '3.1.0.rc5'?
I can't use gem 'rails', '3.1.0.rc5', :git => "git://github.com/rails/rails", :branch => "3-1-stable" on heroku, it just bloats my slug size far too much.
I also get "undefined method `context_class' for nil:NilClass (NoMethodError)"
from sass-rails.
@ncri do you have asset-pipeline enabled as per my comment above?
from sass-rails.
Okay, as a first solution I removed the sass-rails gem - don't need it yet. ;-) Now it works.
from sass-rails.
My asset pipeline is enabled, yes.
from sass-rails.
I have the same problem, and the only way to fix it is the same as @ncri: Remove the sass-rails gem :(
from sass-rails.
I bumped to sass-rails from git and seems to work fine now.
from sass-rails.
It turned out that I forgot to install Node.js and Coffescript (how stupid!) on the server. Installing them, and then reinstalling the last version of sass-rails, solved the problem. YAY!
from sass-rails.
Yep, all works for me too now with rails rc6. I was able to add the sass-rails gem again.
from sass-rails.
fixed by 74c5e4e.
Sass rails will raise an error if the asset pipeline is not enabled -- in these cases the sass-rails plugin should not be used/activated.
from sass-rails.
I am getting the same error mentioned many times in above discussions
"undefined method `context_class' for nil:NilClass"
when trying to do rake db:migrate
Please help.
from sass-rails.
@PrajktaP do you use rails 3.1 rc6?
from sass-rails.
No, its rails 3.1 rc4
from sass-rails.
try upgrading
from sass-rails.
I have upgraded to rc6. Now I am getting following error
Please install the sqlite3 adapter: gem install activerecord-sqlite3-adapter
(sqlite3 is not part of the bundle. Add it to Gemfile.)
from sass-rails.
Yes, then just do it. :) I'm surprised though you didnt get that error with rc4.
from sass-rails.
Thanks for all you responses.
But I am not able to proceed further because of some or the other error :(
from sass-rails.
What do I do with this?
rake aborted!
uninitialized constant Encoding
from sass-rails.
Has it to do anything with my ruby version? I am using 1.8.7
from sass-rails.
Related Issues (20)
- Where is your ChangeLog? HOT 2
- url imports aren't loaded in 6.0 HOT 1
- On Windows search for libsass.so instead of libsass.dll HOT 2
- SassC::SyntaxError: Error: malformed URL HOT 1
- Post-install message about Ruby Sass end-of-life HOT 2
- bundle failed with gem 'sass-rails', '>= 6'
- Depends on sassc-rails? HOT 1
- Moving from import to use HOT 2
- Glob Imports Not Working HOT 1
- SassC::SyntaxError: Error: style declaration must contain a value issue with deploy on heroku server HOT 1
- error compiling assets with image-url tag HOT 1
- Modern color syntax HOT 5
- var(--tw-empty,/*!*/ /*!*/) wrongly processed
- Switch to embedded dart-sass? HOT 4
- Segmentation fault error when precompiling assets HOT 2
- [ARM64] Creating Rails 6.1.5 app in JRuby 9.3.3.0 fails due to sass-rails relying on C library HOT 2
- Error in production mode on RoR 7.0.3.1 with Bootstrap 5.2
- Installation fails on Windows/Jruby 9.3.9.0 HOT 2
- Scss suffixes is not working
- Swap from `sassc-rails` to `dartsass-rails`? Or Deprecate this gem entirely? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sass-rails.