Git Product home page Git Product logo

Comments (59)

rubys avatar rubys commented on August 31, 2024

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.

rubys avatar rubys commented on August 31, 2024

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:

rails/rails@1edfadf

from sass-rails.

josh avatar josh commented on August 31, 2024

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.

 avatar commented on August 31, 2024

same issue here with rails-3-1-stable & sass-rails-3.1.0.rc.5

from sass-rails.

rubys avatar rubys commented on August 31, 2024

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.

rubys avatar rubys commented on August 31, 2024

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.

josh avatar josh commented on August 31, 2024

sass-rails can add a requirement for rails ~> 3.1.0.rc5 and remove any old hacks.

from sass-rails.

chriseppstein avatar chriseppstein commented on August 31, 2024

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.

grk avatar grk commented on August 31, 2024

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.

chriseppstein avatar chriseppstein commented on August 31, 2024

grrr. can someone see if they can fix this? I'm at work now.

from sass-rails.

grk avatar grk commented on August 31, 2024

Wow, github really surprised me with referencing this.

from sass-rails.

spastorino avatar spastorino commented on August 31, 2024

@grk can you provide a failing test case with it?

from sass-rails.

grk avatar grk commented on August 31, 2024

8 specs fail without it.

from sass-rails.

rubys avatar rubys commented on August 31, 2024

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.

josh avatar josh commented on August 31, 2024

That fix doesn't do anything. Its as good as commenting out that code.

from sass-rails.

spastorino avatar spastorino commented on August 31, 2024

@grk commit is wrong, @rubys can you test it now? I've reverted it

from sass-rails.

josh avatar josh commented on August 31, 2024

1af944d

from sass-rails.

jeanmartin avatar jeanmartin commented on August 31, 2024

assuming this fixes the problem, can you add it to the 3-1-stable branch?

from sass-rails.

 avatar commented on August 31, 2024

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.

johnnym avatar johnnym commented on August 31, 2024

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.

jeanmartin avatar jeanmartin commented on August 31, 2024

@josh's commit fixes it but it's not part of the 3-1-stable branch yet...

from sass-rails.

johnnym avatar johnnym commented on August 31, 2024

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.

spastorino avatar spastorino commented on August 31, 2024

Pushed to 3-1-stable

from sass-rails.

huerlisi avatar huerlisi commented on August 31, 2024

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.

spastorino avatar spastorino commented on August 31, 2024

@huerlisi steps to reproduce it? did you run bundle update before? just checking because shouldn't be an issue anymore.

from sass-rails.

huerlisi avatar huerlisi commented on August 31, 2024

@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.

huerlisi avatar huerlisi commented on August 31, 2024

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.

spastorino avatar spastorino commented on August 31, 2024

@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.

huerlisi avatar huerlisi commented on August 31, 2024

@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.

christianparpart avatar christianparpart commented on August 31, 2024

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.

spastorino avatar spastorino commented on August 31, 2024

@huerlisi use 3-1-stable branch of Rails, and master of sprockets and sass

from sass-rails.

spastorino avatar spastorino commented on August 31, 2024

@trapni have you tested with the steps I've provided?, can you provide info on what's wrong?

from sass-rails.

mariozaizar avatar mariozaizar commented on August 31, 2024

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.

johnlauck avatar johnlauck commented on August 31, 2024

@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.

mariozaizar avatar mariozaizar commented on August 31, 2024

@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.

thedarkone avatar thedarkone commented on August 31, 2024

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.

chriseppstein avatar chriseppstein commented on August 31, 2024

@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.

thedarkone avatar thedarkone commented on August 31, 2024

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.

ianrumford avatar ianrumford commented on August 31, 2024

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.

mariozaizar avatar mariozaizar commented on August 31, 2024

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.

ianrumford avatar ianrumford commented on August 31, 2024

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.

ncri avatar ncri commented on August 31, 2024

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.

thedarkone avatar thedarkone commented on August 31, 2024

@ncri do you have asset-pipeline enabled as per my comment above?

from sass-rails.

ncri avatar ncri commented on August 31, 2024

Okay, as a first solution I removed the sass-rails gem - don't need it yet. ;-) Now it works.

from sass-rails.

ncri avatar ncri commented on August 31, 2024

My asset pipeline is enabled, yes.

from sass-rails.

kupkovski avatar kupkovski commented on August 31, 2024

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.

rdeshpande avatar rdeshpande commented on August 31, 2024

I bumped to sass-rails from git and seems to work fine now.

from sass-rails.

kupkovski avatar kupkovski commented on August 31, 2024

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.

ncri avatar ncri commented on August 31, 2024

Yep, all works for me too now with rails rc6. I was able to add the sass-rails gem again.

from sass-rails.

chriseppstein avatar chriseppstein commented on August 31, 2024

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.

PrajktaP avatar PrajktaP commented on August 31, 2024

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.

ncri avatar ncri commented on August 31, 2024

@PrajktaP do you use rails 3.1 rc6?

from sass-rails.

PrajktaP avatar PrajktaP commented on August 31, 2024

No, its rails 3.1 rc4

from sass-rails.

ncri avatar ncri commented on August 31, 2024

try upgrading

from sass-rails.

PrajktaP avatar PrajktaP commented on August 31, 2024

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.

ncri avatar ncri commented on August 31, 2024

Yes, then just do it. :) I'm surprised though you didnt get that error with rc4.

from sass-rails.

PrajktaP avatar PrajktaP commented on August 31, 2024

Thanks for all you responses.
But I am not able to proceed further because of some or the other error :(

from sass-rails.

PrajktaP avatar PrajktaP commented on August 31, 2024

What do I do with this?

rake aborted!
uninitialized constant Encoding

from sass-rails.

PrajktaP avatar PrajktaP commented on August 31, 2024

Has it to do anything with my ruby version? I am using 1.8.7

from sass-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.