Ruby on Rails generates model field:type - what are the options for field:type?

后端 未结 8 1786
遥遥无期
遥遥无期 2020-12-22 15:42

I\'m trying to generate a new model and forget the syntax for referencing another model\'s ID. I\'d look it up myself, but I haven\'t figured out, among all my Ruby on Rails

相关标签:
8条回答
  • 2020-12-22 16:24

    $ rails g model Item name:string description:text product:references

    I too found the guides difficult to use. Easy to understand, but hard to find what I am looking for.

    Also, I have temp projects that I run the rails generate commands on. Then once I get them working I run it on my real project.

    Reference for the above code: http://guides.rubyonrails.org/getting_started.html#associating-models

    0 讨论(0)
  • 2020-12-22 16:24

    http://guides.rubyonrails.org should be a good site if you're trying to get through the basic stuff in Ruby on Rails.

    Here is a link to associate models while you generate them: http://guides.rubyonrails.org/getting_started.html#associating-models

    0 讨论(0)
提交回复
热议问题