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.
2 Comments
Great to step by step posted on this. So what was coolest or most irritating thing you found participating in RailsBridge?
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.
One Trackback/Pingback
[...] 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