Skip to content

migrating a rails app from 2.x to 3.0

I’m sitting here with @gavinstark at major coffee/sandwich chain playing with rails 3.0 for the railsbridge bugmash weekend.

Here’s what I had to do to get the omnominator app migrated to 3.0. Some (most) steps taken from Yehuda Katz’s post.

Check out rails source:

git clone git://github.com/rails/rails.git

Run rails update script

I forked a copy of the omninator code for this; from the root dir of the app:

 ruby /path/to/rails3/railties/bin/rails .

Note that I had to call that with ruby, as it wasn’t pre-set to be an executable ruby script.

I let that overwrite all the script/ files etc.

Note about config/environment

The config/environment.rb now basically just requires config/application.rb, and all the config statements in config/development.rb, etc are wrapped in an initializer block like:

 Myapp::Application.configure do
      config.cache_classes = false
      ...
 end

So, do that for each of your env-specific config files, and (I think) move the config code from environment.rb to application.rb.

config.gem

Gems are now handled in Gemfile, instead of using config.gem in environment.rb etc.

Update the gemfile

Again, from Yehuda’s post, copy this block to your new Gemfile:

 # Add to the top
 directory "/path/to/rails", :glob => "{*/,}*.gemspec"
 git "git://github.com/rails/arel.git"
 git "git://github.com/rails/rack.git"

and then from the root of the app run:

gem bundle

(note that you need to have the ‘bundler’ gem installed, so ‘sudo gem install bundler’ if you need to..)

I had to remove a couple of initializers:

  • Hoptoad notifier initializer fails, so I commented it out for now; I’ll update this post when I figure out the Hoptoad compatibility
  • new_rails_defaults, which was added in 2.x to ease migration, failed under 3.0; that makes sense ’cause it’s redundant now.

That was it. The omnominator is a one-controller basically two-view app, so I’m sure there are other upgrade issues for more complicated apps, but maybe this will get you started.

3 Comments

  1. Great to step by step posted on this. So what was coolest or most irritating thing you found participating in RailsBridge?

    Sunday, January 17, 2010 at 11:59 pm | Permalink
  2. matt wrote:

    My participation was pretty minor — a couple of hours on Sunday, and I didn’t do any bug-mashing to speak of — but the irc channel is a great resource. RailsBridge also did a good job of setting up ‘how do i get started?’ and ‘how do I participate?’ guides, so the most time could be spent on actually working rather than floundering.

    Monday, January 18, 2010 at 9:25 am | Permalink
  3. Internal wrote:

    Hi there, everything is going well here and ofcourse eery one iss sharing information, that’s in fact excellent, keep up writing.

    Sunday, September 21, 2014 at 10:16 am | Permalink

One Trackback/Pingback

  1. Rails 3 Reading Material | Medium eXposure on Sunday, January 24, 2010 at 2:54 am

    [...] Migrating a Rails App from 2.x to 3.0 (01/17/10) — Another tutorial on steps needed to upgrade your Rails app. [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*