Rails 4.0 to 4.2 Upgrade
I recently upgraded an app from Rails 4.0 to Rails 4.2.5. While not as simple as a 0.1 upgrade, this is a fairly straightforward update path with good documentation. But since this is the real world, of course there were snags along the way. I thought I’d take a few minutes to document some of the challenges I dealt with along the way.
Gem dependencies
The first significant issue I ran into was that the Squeel gem is not compatible with the combination of Rails 4.2.5 and ActiveAdmin 1.0.0pre used in the app. Squeel is dependent on Polyamorous ~> 1.1.0, and ActiveAdmin 1.0 requires Ransack ~> 1.3, which in turn requires Polyamorous ~> 1.2.
These kinds of gem dependency issues are part and parcel to Rails version upgrades.
The Squeel gem adds syntactic sugar to your ActiveRecord queries so you can write code like this:
Account.where{ balance > 0.0}
Instead of the more verbose SQL syntax:
Account.where(["balance > ?", 0.0])
Which means I needed to go through the entire app to translate all the code written using Squeel and translate it all back to the typical SQL. This is what happens when you use gems that don’t keep up with the times.
Controller routing issues
I had a custom API controller method making a
get named_path(object, format: json)
which resulted in:
undefined method `get' for <object>...
The fixes:
RSpec.configure do |config| # url helpers allow you to use 'get named_path' syntax in specs config.include Rails.application.routes.url_helpers # In Rspec 3.x the spec type is not automatically inferred from file location config.infer_spec_type_from_file_location!end













