【问题标题】:Directly inheriting from ActiveRecord::Migration is not supported不支持直接从 ActiveRecord::Migration 继承
【发布时间】:2017-11-12 01:27:05
【问题描述】:

我刚刚完成了我的第一个 Ruby on Rails 应用程序,我正在尝试将它部署到 Heroku。我现在处于最后一步,但是当我运行以下命令(heroku run rake db:migrate)时,我收到了这个错误:

StandardError : Directly inheriting from ActiveRecord::Migration is not supported. 
Please specify the Rails release the migration was written for.

网络上的每个人都说你只需要改变

class CreateRelationships < ActiveRecord::Migration

class CreateRelationships < ActiveRecord::Migration[4.2]

问题是这个解决方案对我不起作用。提前谢谢!

【问题讨论】:

  • 您使用的是什么版本的rails(我假设是4.2.x)?您是否更新了所有迁移?
  • 是的,我使用 Rails 4.2 并更新了所有迁移...
  • 这是一个 rails 5 错误,所以 heroku 认为你有 rails 5,我猜这不会在本地发生。您在 gemfile 中的确切版本是什么?

标签: ruby-on-rails ruby heroku activerecord migration


【解决方案1】:

如果您的 ruby​​ rails 版本是 [5.1.5],则添加 [5.1] 甚至......只有 5.1 类 CreateRelationships

喜欢这个帖子。检查最顶部的 gemfile 以查看您拥有的 Rails 版本。

我在之后直接运行 bundle install 并且 我运行了最初显示此错误的命令,然后它就起作用了。不确定您是否需要运行捆绑安装..

希望这会有所帮助 喷出

【讨论】:

    猜你喜欢
    • 2018-07-26
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多