Rails 5的ActiveRecord :: Migration中的[5.0]是什么意思? [英] What’s does the [5.0] in Rails 5’s ActiveRecord::Migration mean?

查看:51
本文介绍了Rails 5的ActiveRecord :: Migration中的[5.0]是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails 5应用程序中创建的迁移已将 5.0 传递给方法:

A migration I created in a Rails 5 application had 5.0 passed into a method:

class CreateVariableKeys < ActiveRecord::Migration[5.0]
  ...
end

我会想知道 [5.0] 是什么意思。

I would like to know what the [5.0] means.

推荐答案

它是 ActiveRecord :: Migration 的类方法,并已定义为此处

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

它允许我们在 4.2之间选择希望使用的迁移版本。 5.0 。该方法抛出:

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.

ActiveRecord 没有该方法,因此 Rails 5 超出beta时应消失。

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

这篇关于Rails 5的ActiveRecord :: Migration中的[5.0]是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆