Lunchpicker is my first project with Rails. Back then, there was alot of hype regarding Rails and that was why I started Lunchpicker
to have a taste of Ruby On Rails. Yes, I fell in love with it immediately.
Wife had some plans for the entire afternoon and I’ve decided to dedicate my entire Saturday afternoon on migrating Lunchpicker from Rails 2 to Rails 3.
Here’s a blog post on my adventure. Thanks @jasoncodes for helping!
1 . Install RVM.
RVM allows you to install, manage and work with multiple ruby environments.
For example, you can have project A running in Ruby 1.8.x and project B running in Ruby 1.9.x
2 . For lunchpicker, here is my .rvmrc file
<div>
$ cat .rvmrc
rvm --create 1.9.2@lunchpicker</code></pre>
3 . Now, we need to intall Bundler.
Bundler manages your application’s dependencies via Gemfile.
Here’s a sample of lunchpicker’s Gemfile
8 . Remove scaffold related html from the public folder
9 . In your helpers, mark your HTML fragements as safe. For example you should change
return <<-HTML
<p>
blah
</p>
HTML
to
return <<-HTML.html_safe
<p>
blah
</p>
HTML
10 . If you have a non ActiveRecord model, and if you’re using Validatable, change it to Informal.
For Lunchpicker, search.rb is not an ActiveRecord model.
Also, we need to change
12 . default.html.haml has been changed to application.html.haml in Rails 3.
Run git mv default.html.haml application.html.haml and don’t forget to remove the application.html.erb as well.
13 . Switch rails.js from Prototype to jQuery. Remove controls.js, dragdrop.js, effect.js and prototype.js. Please see
rails.js.
14 . Add rails.js in the application.html.haml for Unobtrusive Javascript support.
= javascript_include_tag 'rails'
15 . If you run rake db:migrate before step 11, run rake db:reset and then rake db:migrate again.
I hope that this will be useful to you if you need to migrate any old Rails 2 application to Rails 3.
I’ll use this opportunity to add unit test with RSpec.
The Rails 3 version of lunch picker won’t be in production till unit test is done!