未定义的方法`create_enum'在生产中迁移时出错

时间:2015-03-17 20:02:22

标签: ruby-on-rails ruby-on-rails-4 heroku

所以我正在处理一个现有的应用程序,出于某些原因,我能够让它在我的本地环境中工作和镜像,但是当我尝试在heroku上迁移时,我得到以下错误,有任何想法吗?

错误:

 (called from block in <top (required)> at /app/config/environments/production.rb:23)
== 20141119113015 CreateReleasedInventoryStatus: migrating ====================
-- create_enum("eh_released_inventory_status", ["rejected", "pending", "allocated", "released", "transferred"])
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

undefined method `create_enum' for #<CreateReleasedInventoryStatus:0x007fdc5d854c38>/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:661:in `block in method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `block in say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:632:in `say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:652:in `method_missing'
/app/db/migrate/20141119113015_create_released_inventory_status.rb:3:in `change'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:606:in `exec_migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:590:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:589:in `block in migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:588:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:765:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:995:in `block in execute_migration_in_transact

迁移文件:

class CreateReleasedInventoryStatus < ActiveRecord::Migration

  def change
    create_enum("eh_released_inventory_status", ["rejected", "pending", "allocated", "released", "transferred"])
  end
end

1 个答案:

答案 0 :(得分:1)

我认为您使用的是power_enum,并且已在您development的{​​{1}}组中声明。因此,Rails不会在Gemfile环境中加载它并导致此错误。

因此,请检查您的production