在所有这些情况下,忽略父参数:
Rails::Generators.invoke("active_record:model", [name, ["list_order:string", "name:string"], ["parent=Ecm::Toplist::Base"]])
Rails::Generators.invoke("active_record:model", [name, ["list_order:string", "name:string"], ["--parent=Ecm::Toplist::Base"]])
Rails::Generators.invoke("active_record:model", [name, ["list_order:string", "name:string"], "parent=Ecm::Toplist::Base"])
Rails::Generators.invoke("active_record:model", [name, ["list_order:string", "name:string"], "--parent=Ecm::Toplist::Base"])
这是一个错误,还是我错过了什么?
答案 0 :(得分:0)
正确的方式将是
Rails::Generators.invoke("active_record:model", [name, "list_order:string", "name:string"], { parent: "Ecm::Toplist::Base"})
但是请注意,根据this,一旦指定:parent,就不会调用迁移。
使用迁移生成模型的正确方法是
Rails::Generators.invoke("active_record:model", [name, "list_order:string", "name:string"], {migration: true, timestamps: true})