Table of contents

Upgrade Rails to a new version

When upgrading our apps between Rails major and minor versions, follow the [official Rails guides][guide].

Rails configs

We are trying to standardise our Rails config files. The guidelines for these are as follows:

  • If load_defaults is used, it should be top of the config
  • Config options should be alphabetised
  • Group together options that relate to the same option
    • E.g. config.assets.enabled and config.assets.prefix should be grouped together
  • Remove any default/unnecessary comments

Gotchas for upgrading to Rails 5.1

Schema dumper changes

The schema dumper has been refactored in Rails 5.1 so the first migration after upgrading will generate a lot of differences in db/schema.rb. Notably whitespace and using :btree index modifiers. See this commit and also this commit for details of the changes.

As part of the upgrade, regenerating the schema with rake db:migrate and including the updated db/schema.rb file will mean the next migration doesn’t generate this noise.

This page was last reviewed . It needs to be reviewed again by the page owner #govuk-2ndline.