Upgrading to Rails 5 Beta 1

My post on upgrading to rails 4.2 is now over a year out. The new beta has been out since December and it's time to try the New Hotness™.

To start I'm using this blog post from heroku. The following are my impressions in upgrading a recent rails 4.2.5 project.

Getting the New Goodness

First things first. You'll need to update your Gemfile to use the current version straight from git. This is the bleeding edge people!

# Gemfile
gem \"rails\", github: \"rails/rails\", ref: \"dbf67b3a6f549769c5f581b70bc0c0d880d5d5d1\"

The heroku post also recommended using ruby 2.3.0 so

$ rbenv install  2.3.0-dev

and then

$ rbenv use  2.3.0

This took a while. Having not read why 2.3.0 is better I rather regretted this step, since my 2.2.2 was just fine.

Also 2.3.0-dev is calling itself 2.4.0-dev. So another update to the Gemfile.

Next I had to re-install bundler for the new version of ruby.

$ gem install bundler --no-ri

Dealing with the Old Stuff

Granted we're on the bleeding edge, so even the awesome stable stuff from a project earlier this month is now old and busted. I'm not expecting everything to work out of the box. These are just my update notes.

Broken Gems

At first I naïvely went for a straight bundle install. And this almost worked, but there were a few gems bundler wasn't able to resolve dependencies for. After doing the more appropriate bundle update, I installed several more brand new gems with less trouble.

  • AwesomePrint - initially I had an issue with the gem, but installing directly from github after a bundle update did the trick.

  • state_machines-activerecord - Tried updating to the current version on github, but it still wouldn't resolve bundlers version check. I'll have to wait on the state_machine goodness until later.

  • Devise - working without this one was a non-starter. Luckily I just had to pull in the github master and things started working

gem 'devise', github:'plataformatec/devise', branch: 'master'

Other Errors

undefined method 'clean' for Hash

A little searching initially implicated that this was from Devise, although the error seems to be actually from meta_request

Shim Gems

Apparently a few things were taken out of rails-core. I've never actually used them (maybe why they were taken out?) but record_tag_helper and rails-controller-testing are there if you need them.

Fix the Tests

once I officially had the console and the server working it was time to work out the kinks from rspec:

Deprecation Warnings

DEPRECATION WARNING: serve_static_files is deprecated and will be removed in Rails 5.1.
DEPRECATION WARNING: static_cache_control is deprecated and will be removed in Rails 5.1.

The lovely console error message told me how to update with a quick trip to /config/environments/test.rb.

```language-bash DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks ``` This required the removal of the following lines from `config/application.rb` ```language-ruby # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true ```
```language-bash undefined method filter_rails_from_backtrace! ```

For some reason, removing the version from rspec downgraded me to 3.1. Installing from master fixed this. (I also had to lose the fuubar gem)

Since rspec is modularized, the github page recommends the following in your Gemfile

%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
  gem lib, :git => \"https://github.com/rspec/#{lib}.git\", :branch => 'master'

Running Rails Update

Almost done, now to see the new default config files that ship with Rails 5. Here are the most interesting ones:

  • routes.rb
    This file adds defaults for using action cable
  • config/environments/development.rb
    featuring new updates for the new rake task to enable/disable caching in development. Also an optional config for asynchronously watching for file changes.
  • config/environments/production.rb
    Rack-cache config is now removed. Logs now log the request_id be default. A new setup for distributed logging and advise for setting up a 'real' queuing backend for active job.
  • bin/setup — A few updates for better system call handling with missing flags
  • config/initializers/cors.rb — example defaults for dealing with cross-origin resource sharing.
  • config/redis/cable.rb — Looks like redis is now required for action cable

New Stuff

after getting this up and running, I'm happy to play with a few new things


Rails 5 now has websockets. I feel like the obligatory chat demo should happen.

New API Mode

Won't do this with the current project, but will definitely try this with a javascript front end.

ActionMail Previews

This is actually part of 4.1+, but I happened to run into it while debugging some things. Cool that it's here.