在生产中迁移时,不会将Symbol隐式转换为整数 [英] no implicit conversion of Symbol into Integer when migrating in production
问题描述
因此,我正在开发一个现有的应用程序,出于某种原因,我能够使其工作并在本地环境中进行镜像,但是当我尝试在heroku上迁移时,出现以下错误,有任何想法? b
$ b
错误:
== 20141119113015 CreateReleasedInventoryStatus:migrating = ===================
- create_enum(eh_released_inventory_status,[rejected,pending,分配,释放,转移])
rake中止!
StandardError:发生错误,此次及以后的所有迁移都已取消:
无符号转换为Integer / app / vendor / bundle / ruby / 2.0.0 / gems / power_enum- 2.8.0 / lib / power_enum / schema / schema_statements.rb:84:在`[]'
/app/vendor/bundle/ruby/2.0.0/gems/power_enum-2.8.0/lib/power_enum/ schema / schema_statements.rb:84:在`create_enum'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:662: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:在`method_missing'
/app/db/migrate/20141119113015_create_released_inventory_status.rb:3:in`change'
/ app /供应商/束/红宝石/ 2.0.0 /宝石/了activerecord-4.2.0 / LIB / active_record / migration.rb:606:在`exec_migration'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:590:in`block (2级)迁移'
/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
迁移文件:
class CreateReleasedInventoryStatus< ActiveRecord :: Migration
def change
create_enum(eh_released_inventory_status,[rejected,pending,allocated,released,transferred])
end
end
我也使用以下gem:
gem'power_enum'
$ b $您的迁移语法似乎对您正在使用的 power_enum
gem不正确。
宝石的自述文件表示该语法使用名称,然后是一个选项散列,如:
$ p $ create_enum(status,{...})
您使用的是名称,然后是数组:
create_enum(eh_released_inventory_status,[...])
可以说,解决方案是改变你发布的迁移线o power_enum
语法。自述文件包含大量示例,并且看起来很全面,并且非常详细。
So I'm working on an existing app and for some reason I was able to get it working and mirrored on my local environment however when I try migrating on heroku I get the below error, any ideas?
Error:
== 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:
no implicit conversion of Symbol into Integer/app/vendor/bundle/ruby/2.0.0/gems/power_enum-2.8.0/lib/power_enum/schema/schema_statements.rb:84:in `[]'
/app/vendor/bundle/ruby/2.0.0/gems/power_enum-2.8.0/lib/power_enum/schema/schema_statements.rb:84:in `create_enum'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.0/lib/active_record/migration.rb:662: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
Migration file:
class CreateReleasedInventoryStatus < ActiveRecord::Migration
def change
create_enum("eh_released_inventory_status", ["rejected", "pending", "allocated", "released", "transferred"])
end
end
I'm also using the following gem:
gem 'power_enum'
Your migration syntax seems to be incorrect for the power_enum
gem that you're using.
The gem's README says the syntax uses a name, then an options hash, such as:
create_enum("status", {…})
Whereas you're using a name, then an array:
create_enum("eh_released_inventory_status", […])
As far as I can tell, the solution is to change your migration line from what you posted to the power_enum
syntax. The README has a bunch of examples, and also looks like it's thorough and very well documented.
这篇关于在生产中迁移时,不会将Symbol隐式转换为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!