Let’s talk about pretty tedious task - upgrading rails, of course it can be interesting experience, but if you have relatively large application to upgrade it can be cumbersome, here are my thoughts after doing through process of switching Rails 3.2 to Rails 4.1.
the basic thing - test suite. Few integration specs are better than none, obviously. Make sure it’s nice & green before even starting the process
rails upgrade guide will give you some tips & hints about what changes, what may brake etc. Must read.
if you’re using observers you will need to include
rails-observers
gem and if you’re not ready to implement strong attributes - go withprotected_attributes
Dependencies. I’m guessing you are not running vanilla rails application, but you rather packed your Gemfile with some open source goodies. That’s cool, but keep in mind that most of the gems will probably need upgrading as well.
bundle outdated
command will help you track down what gems needs upgrading. I recommend checking out Changelog/History in gem’s repository (if provided) - sometimes you will need to take some additional steps during the upgrade process, but fortunately most of the popular gems are pretty well documented.if you are using rspec, there is a big chance that your test suite still uses old
should
syntax. There is a really cool tool called Transpec that will help you automatically upgrade your whole test suite (even from rspec2 to rspec3)some more complex SQL queries (joins with custom select etc.) won’t allow you to do
count
- to reproduce old (Rails 3) behavior you have to call it with:all
argument -count(:all)
watch our if you’re using
EXIST
query - I noticed that rails 4 returns boolean, where in 3.2 you got ’t’ / ‘f’ string (postgresql)using cancan? Cool - but check out it’s successor called cancancan - it’s very actively maintained by open source community
Rails 4 comes with default headers that will block running your app from iframe - if you would like to disable this behavior put this in your application config:
config.action_dispatch.default_headers = { # documentation specifies ALLOWALL, but empty string # should work across all common browsers 'X-Frame-Options' => '' }
The list goes on, but every app is different, so I will stop here and wish you best luck with your upgrade process ;-). Let the 200 response status be with you, always.