Rails: Fix your 3.1 beta 1 sprockets problem
So, Rails 3.1 is barely out, and being the brick-wall bashing guinea pig I am, I am ready to rock with it. One problem, sprockets is borked upon install, since rails 3.1 needs sprockets 2.0.0.beta.2 and if you just bundle install it gives you sprockets 2.0.0.beta.4, too new for school. Here’s how to unbork your bundled rails 3.1 install.
If you are getting error messages like undefined method `context’ for Sprockets::Environment:0x00000002535fa0 (NoMethodError) this is how you fix it:
You have to open up the gemfile in your rails app (whatever folder you were in when you told it rails new appname), and add this line:
gem ‘sprockets’, ’2.0.0.beta.2′
Then in terminal (or command prompt on windows) you have to run bundle update sprockets and it will grab the beta.2 version of sprockets needed by rails to run correctly. Sprockets is the thing that turns javascript files into cleaned up code and combines it all into one file for use by pages.
Now, try to run scaffold or whatever broke before and it should run like a champ.

Thanks that worked for me and like you I always have to have the latest and greatest
Thanks a lot!
I'm still having this exact problem. I can install it on my Mac, but when I try on my Ubuntu server I get the following:
Could not find gem 'sprockets (= 2.0.0.beta.2)' in git://github.com/sstephenson/sprockets.git (at master). Source contains 'sprockets' at: 2.0.0.beta.13
I think the problem is that the source on git is too new for what your gemfile is looking for. If you download the b2 version from git (go here: https://github.com/sstephenson/sprockets/tree/v2…. ) you should be able to get it to work, or change your gemfile to reflect the version you have (13). You have to install and reference the same version. You may have to download manually (not via git) and dump the files onto your hard drive.