gnerkus gnerkus - 1 month ago 5x
Ruby Question

What’s does the [5.0] in Rails 5’s ActiveRecord::Migration mean?

A migration I created in a Rails 5 application had

passed into a method:

class CreateVariableKeys < ActiveRecord::Migration[5.0]

I would like to know what the


It is a class method of ActiveRecord::Migration and is defined here.

It allows us to select the version of migrations we wish to use between 4.2 and 5.0. The method throws a:

"Unknown migration version ... "

error if an incompatible version is passed as an argument.

Production ready versions of ActiveRecord don’t have that method so it should go away as soon as Rails 5 goes out of beta.