<commit_before>---
owner_slack: '#2ndline'
last_reviewed_on: 2017-04-28
review_in: 6 months
title: Upgrading Rails
section: Packaging
layout: manual_layout
parent: "/manual.html"
---

# Upgrade Rails

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

## Gotchas for upgrading to Rails 5.0

### Eager loading

Add `lib` to the autoload path if required, see [Travel Advice Publisher](https://github.com/alphagov/travel-advice-publisher/blob/453b81341dba646178b4421ddab705bdd36deb22/config/application.rb#L37)
for an example.

### Airbrake

Upgrading to Rails 5 requires upgrading the Airbrake gem. This breaks some compatibility with
our Errbit installation, namely that deployments are no longer recorded.

### Don't include ActionCable or Puma configs

We don't use these in production and are likely to cause conflicts.

[guide]: http://guides.rubyonrails.org/upgrading_ruby_on_rails.html<commit_msg>Correct the eager load explanation<commit_after>---
owner_slack: '#2ndline'
last_reviewed_on: 2017-04-28
review_in: 6 months
title: Upgrading Rails
section: Packaging
layout: manual_layout
parent: "/manual.html"
---

# Upgrade Rails

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

## Gotchas for upgrading to Rails 5.0

### Eager loading

By default Rails 5 disables autoloading in production and uses eager load, this
[blog post][rails-5-autoloading] explains further.

The effect this can have is that classes that need the `autoload_paths` altered -
for instance at the root of `lib` - will no longer work in production, but will
still load in development (this has already caused a production issue).

The solution is append to `eager_load_paths` rather than `autoload_paths` which
will ensure the classes are loaded in both production and development. See
[Publishing API Example][publishing-api-autoload-change].

### Airbrake

Upgrading to Rails 5 requires upgrading the Airbrake gem. This breaks some compatibility with
our Errbit installation, namely that deployments are no longer recorded.

### Don't include ActionCable or Puma configs

We don't use these in production and are likely to cause conflicts.

[guide]: http://guides.rubyonrails.org/upgrading_ruby_on_rails.html
[rails-5-autoloading]: http://blog.bigbinary.com/2016/08/29/rails-5-disables-autoloading-after-booting-the-app-in-production.html
[publishing-api-autoload-change]: https://github.com/alphagov/publishing-api/pull/553/files
{'fraction_non_alphanumeric': 0.08353127474267617, 'fraction_numerical': 0.026920031670625493, 'mean_word_length': 5.178484107579462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '652588', 'n_tokens_mistral': 841, 'n_tokens_neox': 742, 'n_words': 277}