Rails 5 is almost upon us and we’ve spent the last two months, amongst other things, moving our 45,000 lines of Rails e-commerce code from 3.2 to 4.2. For better or worse the move has been less about embracing new features and more about compliance and maintaining security bug fix support. The move has been a rapid succession of stages, from 3.2 to 4.0 in development, 4.1 in production, and finally 4.2 in production. Overall it has been a significant effort and a learning experience.
The biggest challenge we encountered was not fixing our 175 models and 40 controllers, but dealing with our nearly 100 open source gem dependencies. The project started from a proof of concept elegantly scaffolded with ActiveAdmin’s DSL and has accreted functionality and third party interfaces for the past four years. ActiveAdmin remains the leading Rails admin interface, but with the departure of Greg Bell momentum has slowed. Sean Linsley, Timo Schilling and others have put a significant amount of effort into answering questions and applying bug fixes, but the ambitious 1.0 milestone has remained unmet for two years, and gem releases have been infrequent. To update ActiveAdmin first we switched from stable 0.6 gems to the master branch in GitHub, replacing meta-search with ransack, then we worked our way down the master branch to 1.0.0.pre1 in 90 day increments, isolating and working around the issues that impacted us (#2233, #2679, #2771, #3038/#3324, #3145, #3147, #3486, #3591, #3776, #3784). Critical to this effort was our test suite coverage, which remains a disappointing, but so far adequate, 90% (and yes, we upgraded to RSpec 3.x as well).
Apart from gem dependencies the most dramatic issue updating Rails was the breakage of non-strict mode used with our old MySQL database (and thus nearly everything). For Rails 4 we needed to configure ‘strict: false’ to ignore our true mode setting in the database, then with Rails 4.2 this changed again and we needed to explicitly set variable sql_mode to the required value.
So what has Rails 4.x brought us? ActiveRecord foreign keys and enums, but we embraced the foreigner and enumerize gems long ago. Spring, but we so loved Zeus. secrets.yml but we already use environment variables and dotenv. Web Console, but we are happy with Better Errors and Pry. An improved cookie serializer that fouled up our ‘seamless’ rolling production upgrade. Autoloader vexation. Millisecond DateTime rounding errors (or is that due to OS X?). ActionMailer::Preview and ActionMailer#deliver_later, but we have already built out more sophisticated solutions. Strong parameters for sure. New bin/ scripts. Stricter routing with Patch. An end to ActiveRecord’s old dynamic finder API and tweaks to callbacks and ActiveRecord::Relation. Better performance, please, from Aaron’s AdequateRecord. ActiveJob as a wrapper for Resque or Sidekiq. ActiveSupport::Testing::TimeHelpers. Perhaps for us most importantly a step closer to greater concurrency with Puma (and LiveStreaming?), Sidekiq, Celluloid, who knows?
More detailed ActiveAdmin update notes