以编程方式调用 active_record 生成器:如何传递父参数?
在所有这些情况下,父参数都会被忽略:
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"])
这是一个错误,还是我遗漏了什么?
The parent argument is ignored, in all of these cases:
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"])
Is this a bug, or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的方法是
但是要小心,根据 this 一旦指定:parent,迁移将不会被调用。
通过迁移生成模型的正确方法是
Correct way will be
But be careful, according to this once you specify :parent, the migration will not be invoked.
The correct way to generate model with migration will be