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.

4 Comments

Leave a Reply

You must be logged in to post a comment.