Rails 3 Beta 3 hit the streets a few days ago and I was able to upgrade with only a few issues to sort out. This post covers the issues I had and how I overcame them.
First off I updated my rvm to the latest 1.9.2-head:
rvm install 1.9.2-head
This can be a little risky as head is constantly changing so if you have a revision of 1.9.2 that you are happy with then stick with it unless you are getting some strange problems and an update might help.
Next I installed the latest rails prerelease using:
gem install rails --pre
And updated my
Gemfile to reference beta 3:
gem 'rails', '>=3.0.0.beta3'
When I tried to start up the server I got the following error:
$ rails s /Users/kris/.rvm/gems/ruby-1.9.2-head/gems/rails-3.0.0.beta3/bin/rails:1:in `require': no such file to load -- rails/cli (LoadError) from /Users/kris/.rvm/gems/ruby-1.9.2-head/gems/rails-3.0.0.beta3/bin/rails:1:in `<top (required)>' from /Users/kris/.rvm/gems/ruby-1.9.2-head/bin/rails:19:in `load' from /Users/kris/.rvm/gems/ruby-1.9.2-head/bin/rails:19:in `<main>'
The error turned out to due to a change that moved the rails binary file to a different location. This meant that older versions of the gem were conflicting due to incorrect paths. A simple
gem clean fixed it and the server was able to start. Note that
gem clean will remove all old versions of installed gems - you may be able to remove the specific old version of rails to fix the issue.
The next error was the deprecation warning for the
error_messages helper method. I strongly agree with the removal of this, but it did worry me at first as I often use it when putting together a quick sample app. Not to worry as the generators now generate the HTML into the view directly rather than using the helper so I simply generated another resource and copied and pasted the markup around. You can copy and past the following snippet if it helps, or even put it into a partial and reuse it:
<% if @comment.errors.any? %> <div id="error_explanation"> <h2><%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:</h2> <ul> <% @comment.errors.full_messages.each do |msg| %> <li><%= msg %></li> <% end %> </ul> </div> <% end %>
Perhaps generating the partials would have made the transition a little easier and DRYer. However, in a real app the likelihood is that you would want to create a more awesome error highlighting look ‘n’ feel and therefore this is a minimalist starting point that is still functional.