Skip to content

Upgrade to Rails 5.1

Kari Matthews edited this page Feb 28, 2018 · 2 revisions

Upgrade to Rails 5.1

Change Rails version in Gemfile gem 'rails', '~> 5.1'

Change disco_app to use 0.14.0

Remove gem 'rails-bigint-pk'

Change gem 'activeresource', git: 'https://github.com/shopify/activeresource.git', tag: '4.2-threadsafe' to gem 'activeresource'

Run bundle update

If bundle completes successfully, have a cold beverage! Otherwise follow the errors. See below for some changes I had to make in mms-campaigns.

Once bundle is successful, rails app:update Go through conflicts and check diff carefully. In most cases you don't need to change anything. In mms-campaigns I made minor changes to bin/rails, bin/setup, config/boot, config/environment.

Remove this line from config/application.rb: config.active_record.raise_in_transactional_callbacks = true as it is depreciated and default behaviour in Rails 5.

Delete config/initializers/bigint_pk.rb

Follow the official guide to make your models to inherit from ApplicationRecord etc.

Notes

When upgrading mms-campaigns, I had to change/add following gems in Gemfile:

gem 'coffee-rails', '~> 4.2.0'

gem 'acts_as_paranoid', github: 'ActsAsParanoid/acts_as_paranoid'

gem 'rails-controller-testing' gem 'minitest', '~> 5.10'

Also, added Minitest::Reporters.use! to test_helper.rb

Changed initializers/shopify_session_storage.rb to:

if Rails.configuration.cache_classes
  ShopifyApp::SessionRepository.storage = DiscoApp::SessionStorage
else
  reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader
  reloader.to_prepare do
    ShopifyApp::SessionRepository.storage = DiscoApp::SessionStorage
  end
end

Had to rewrite several yml files, due to changes with JSON/JSONB serialization

For example,

  data: '{ "country_name": "Australia", "timezone": "(GMT+10:00) Melbourne" }'

refactored to:

  data:
    country_name: 'Australia'
    timezone: '(GMT+10:00) Melbourne'

or

  properties: '[{ "name": "gender", "value": "male" }]'

refactored to:

  properties:
    - name: 'gender'
      value: 'male'
Clone this wiki locally