Upgrade To Rails 3.0.10 And Ruby 1.9.2 Reviewed

ruby on rails 3 upgradeOver a year ago (!) I announced my intention to upgrade mightyvites.com from Ruby 1.8.7 and Rails 2.2.2 to Ruby 1.9.2 and Rails 3. Took me long enough but I’m now finally following up on the issue.

No, it didn’t take me a year to do the upgrade. Shortly after I wrote that post I took a full time Rails job. Then my business got busy with paying customers. Then I got engaged and a few months later married. There were a lot of distractions which kept throwing me off my Ruby On Rails upgrade plans. I did do it though. In fact I completed two Rails upgrades this summer. One for mightyvites.com and one for my employer. In both cases I transitioned webapps from Rails 2.x to Rails 3.0.10 and introduced Ruby 1.9.2. Doing so was definitely worth it. Rails 3 feels so much more mature than previous releases. The upgrade, however, was not easy. Below are the issues I had to deal with to make it happen.

Changes in Rails

  • The Rails.root/lib directory must be autoloaded
  • My use of JRails could be dropped due to the new UJS approach of JavaScript handling
  • #fields_for and #form_for require <%= ERB blocks
  • @controller was deprecated for #controller
  • ApplicationController#filter_parameter_logging is now config.filter_parameters in application.rb
  • Must mark application HTML as html_safe due to XSS protection being the default
  • No more CGI::Session::CookieStore::TamperedWithCookie (because of signed cookies?)
  • #rescue_action_in_public usage changed to #rescue_from (really a Rails 2.3 change)
  • Awful “You have a model in a subdirectory, where the name of the subdirectory matches the name of the model.” problem (succinct explanation (point 4), technical explanation)
  • Terrible “incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)” problem caused by rendering XLS file with render :file =>. Fixed by using #send_file
  • ActiveRecord attributes with errors are displayed in a form_for with CSS class ‘field_with_errors’ as opposed to the preveious ‘fieldWithErrors’
  • Had to uncomment the Nginx version of config.action_dispatch.x_sendfile_header in production.rb

Changes in Ruby gems

Changes in Ruby

  • Array#choice now #sample
  • YAML lib changes to Psych; can no longer handle ypaths with #select
  • Drop use of FasterCSV because it is now the native CSV


I would say the average time it took for me to do each upgrade was 3 weeks. A full test suite was invaluable in tracking the state of the upgrade, and after launch I inevitably found bits of un-html_safe’d output. I released the Rails 3 upgrade of mightyvites.com in September of ’11. Since then I’ve upgraded the site to Rails 3.1 and instituted the new asset pipeline. Hopefully I’ll write about that sooner rather than later.

Incoming search terms:

  • rails 3 rescue_action_in_public
  • rescue_action_in_public rails 3
  • upgrade to rails 3 0 10
  • rails rescue_action_in_public
  • ruby 3 0 10
  • rails 3 0 10 changes
  • send_data rails 3 0 10
  • update to rails 3 0 10
  • upgrade rails 2 to 3
  • inauguration invitation background

Leave a Reply