0
我在rails中使用了Singe表繼承。mongo load_models在STI中使用枚舉內部導軌時出錯
module ModuleName
class ParentClass < ActiveRecord::Base
enum status: {OPEN: 'open', CLOSED: 'closed'}
end
end
module ModuleName
class ChildClass1 < ParentClass
end
end
module ModuleName
class ChildClass2 < ParentClass
end
end
遷移和本地主機服務器運行正常,但是上執行命令: -
bundle exec rake db:mongoid:remove_indexes
或
bundle exec rake db:mongoid:create_indexes
我得到的錯誤。
ArgumentError: You tried to define an enum named "status" on the model "ModuleName::ParentClass", but this will generate a instance method "status=", which is already defined by another enum.
Tasks: TOP => db:mongoid:remove_indexes => db:mongoid:load_models
作爲命中和試用,我嘗試從父類中移除狀態枚舉,並將它們分別放入子類中。不工作。
在因特網上找不到任何相關幫助。 任何幫助或建議表示讚賞。 謝謝。