Skip to content
mengfung.com
writing

Upgrading Rails 5.2.2.1 to 6.0

 ·  1 min read

Update Gemfile

<code># update gem 'rails', '~> 5.2.2.1' to
gem 'rails', '~> 6.0.0'
# add
gem 'webpacker', '~> 4.0'</code>

Grab updates & install webpack

<code>bundle update
bin/rails webpacker:install</code>

Run your test and fix any issues. I mostly got issues revolving around update_attributes and expanding where.not() queries.

I had to update a bunch of
@resource.update_attributes(resource_params)
to
@resource.update(resource_params).

I also had scopes that looked like:

<code>scope :complete, -> { where.not(resume_id: nil, cover_letter_id: nil, company_id: nil) }</code>

They had to be updated to:

<code>scope :complete, -> { where.not(resume_id: nil).where.not(cover_letter_id: nil).where.not(company_id: nil) }</code>

Also, I had an issue with one of my render partials.

<code>Failure/Error: &lt;%= render partial: :company_datum, collection: @company_data, locals: { offset: @company_data.offset }, cached: true %></code>

Had to update it to:

<code>&lt;%= render partial: 'company_datum', collection: @company_data, locals: { offset: @company_data.offset }, cached: true %></code>

Updating application.rb

<code># config/application.rb
# change config.load_defaults 5.2
config.load_defaults 6.0
# I removed
config.i18n.fallbacks = &#91;I18n.default_locale]</code>

If using rubocop: add this to your .rubocop.yml

<code>AllCops:
Exclude:
- 'node_modules/**/*'
...</code>

Fin.