Upgrading from Rails 4 to Rails 5

Find out what is new on Rails 5 click here.

application_record

Rails 5 by default will have application_record.rb in app/models/ similar to application_controller.rb.  Simply create app/models/application_record.rb and update all models to inherit from ApplicationRecord instead of ActiveRecord::Base.

# app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end

# Rails 4
# app/models/order.b
Class Order < ActiveRecord::Base
end

# Rails 5
# app/models/order.b
Class Order < ApplicationRecord
end

Update Gemfile

gem ‘rails’, ‘~> 5.1.4

Run “bundle update rails” to get newest Rails 5

Update all your gems version that is compatiblewith Rails 5.

gem ‘exception_handler’, ‘0.7.0’
gem ‘cancancan’, ‘~> 2.0’
gem ‘factory_bot_rails’ instead of ‘factory_girl_rails’
gem ‘rspec-rails’, ‘~> 3.6’

Check Deprecations

  • Filter callbacks  are removed
    • after_filter, before_filter and around_filter
  • render nothing: true is removed
  • content_tag_for and div_for splitted into a gem
  • respond_with and class level respond_to are removed
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s