Getting Ready for Rails 2.0
So Ruby on Rails 2.0 is coming up very soon and I’ve been converting all of my applications ready for it.
If your not already on edge rails then you should be getting ready to upgrade too, since I’ve done about 4 apps now I’m getting into a nice flow so I thought i’d provide a little help in the form of a list:
-
Upgrade to Rails 1.2.4 - The first thing to do is update your version of rails to 1.2.4, this is like the final bugfix-stopgap before the big jump, it can handle most of the rails 2.0 changes but also works with 1.2.3 and moans loudly about code that won’t work in 2.0.
-
Check for Deprecated code - Download a copy of this pastie: http://pastie.caboo.se/private/krcevozww61drdeza13e3a, call it r2check.rb, put it in the root of your app and run it:
ruby r2check.rbThis will tell you about all of the changes that may effect you in the change to 2.0 and how to fix them as well as which files have the offending code, make sure that everything on the list is fixed and you should be good to go.
-
Convert your .rhtml files to .html.erb - 2.0 is changing view templates slightly, instead of .rhtml and .rxml extensions they are now .html.erb and .xml.builder, you don’t have to use this convention but everyone else is and it’s really simple to change it that I think you should.
I’ve taken this rake task and modified it slightly so that it works for partials as well, Download it from this pastie: http://pastie.caboo.se/105340 and save it in your lib/tasks directory, then just run:
rake views:renameAnd it will run through your whole app changing all the filenames and even doing the svn mv as it goes, sit back and enjoy!
Don’t forget to do a find-all for ‘.rhtml’ over your whole app incase your any of your controller/helper code has .rhtml hardcoded into it.
-
Ensure all of your plugins and gems are up to date - If you’ve install plugins a while ago they may have been updated to work better for Rails 2.0, you may as well check all of your installed plugins and gems at the same time. You might even get some performance and security upgrades in the process.
sudo gem updateI use Piston for my plugins which gives similar functionality to gems with updates and management in a nice way, if you are not using it you’ll have to manually go through your plugins and upgrade them all, otherwise use:
piston up
So things should be looking pretty rosey, make sure all your tests are still passing (if you have any) and fingers crossed you’ll be ok when 2.0 rolls in the door, but as always be sure to check your app completely before deploying it to production.
You can read more about the upcoming Rails 2.0 and all the lovely new improvements here: http://weblog.rubyonrails.com/2007/9/30/rails-2-0-0-preview-release
Hope this helps everyone keep up to date with the hottest version of Rails so far!
Update: Rails 1.2.5 is out with more bug fixes and more backporting of Rails 2.0 features, you should get this one instead of 1.2.4




Andrew, my man, ace article. Meh. ROR seems all to complicated for me. mind, i’m still learning that php stuff.
James the Man Bayliss on October 9, 2007 5:21 pm
And I thought php was too complex, ruby makes it a real joy, have you seen the “weblog in 15 mins” screencast?
http://media.rubyonrails.org/video/rails_take2_with_sound.mov
Andrew on October 9, 2007 5:23 pm
why would you learn php if you can learn rails..
great article, will upgrade to rails as soon as possible
Patrick on October 9, 2007 8:34 pm
i finally got hosting with rails so hopefully, with 2.0 coming up, i can dive into it (again)
stabani on October 10, 2007 12:17 am
[…] if you are already riding the rails train then you’ll want to check out this blog post to get your apps ready for 2.0 as soon as […]
Teabass - Andrew Nesbitt's Blog » Ruby on Rails 2.0 Preview Release on October 21, 2007 6:03 pm
Man.. thanks so much for that rake task!
Matt on October 22, 2007 10:55 pm
No probs Matt
Andrew on October 22, 2007 11:12 pm