Migrating to Rails2.1
Hurrah! Rails-2.1 is out and is too tempting. Its time to jump start the migration. Though my team uses SVN, I use git and connect to svn using git-svn. This provides me an opportunity to try out rails-2.1 on our website fundu.mobi without disrupting the flow. Git makes it so easy to create my own branch on my system and test the latest stuff without fear. And anybody out there who wants to live on edge, must use GIT. This and a few posts after this will focus on my journey to Rails-2.1. To recap new features in Rails-2.1 are mentioned in great detail here. So now lets jump into the process.
Before I begin here are my system details
- OS: Ubuntu (Hardy)
- Ruby: 1.8.6
- Git installed
Freeze Rails-2.0.2
I am still in my master branch. I unpacked Rails-2.0.2 into vendor/rails directory. I should have done it earlier, but better later than never. Luckily we are using VPS (slicehost) so we had control on which version of rails we wanted to run. However to try experimenting with Rails-2.1, I decided it would be better if I remove any dependency on system rails gem. Tested this change out and committed changes to master. To get 2.0.2 from git use the following steps
git clone git://github.com/rails/rails.git vendor/rails
cd vendor/rails
git checkout v2.0.2
Create Branch
Now I created a branch with name rails2.1
git checkout -b rails2.1
Freeze Rails-2.1
Checkout Rails-2.1 tagged version from github
cd vendor/rails
git checkout v2.1.0
Changes to Config
Before doing anything I had to run the following command to update the configuration files to work with 2.1
rake rails:update
I also had to remove the following line from environment/development.rb
config.action_view.cache_template_extensions = false
Now I verified the setup by running ./script/console and checked that there are no errors or warnings in the logs.
Umm lets try to run the server, and there comes my first hurdle! when I try to visit the home page of the app I get
Could not find RubyGem activerecord (>= 1.10.1) /usr/local/lib/site_ruby/1.8/rubygems.rb:523:in `report_activate_error' /usr/local/lib/site_ruby/1.8/rubygems.rb:131:in `activate' /usr/local/lib/site_ruby/1.8/rubygems.rb:155:in `activate' /usr/local/lib/site_ruby/1.8/rubygems.rb:154:in `each' /usr/local/lib/site_ruby/1.8/rubygems.rb:154:in `activate' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require' vendor/rails/activesupport/lib/active_support/dependencies.rb:354:in `new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:509:in `require' app/controllers/welcome_controller.rb:1 /usr/bin/thin:19:in `load' /usr/bin/thin:19 This error occurred while loading the following files: feed_tools
Seems like the above error was because of some strange dependency of AR in feed_tools. I unpacked feed_tools to vendor directory and somehow the error was no more. More investigation on this later, lets move on.
That’s about it, website is running as before.