我试图生成一个新模型,并忘记引用另一个模型的ID的语法。我自己也会去查,但我还没有在所有Ruby on Rails文档链接中找到确切的源代码。
$ rails g model Item name:string description:text
(这里是reference:product
或references:product
)。但更好的问题是在哪里或如何,我能在将来轻松地寻找这种愚蠢吗?
注意:我已经学会了一种艰难的方式,如果我错误输入这些选项中的一个和运行我的迁移,那么Ruby on Rails将完全搞砸我的数据库…而rake db:rollback
对这种错误无能为力。我确定我只是有些地方不明白,但在我明白之前…rails g model
返回的“详细”信息仍然让我抓挠…