Drew Johnson
Drew Johnson

Reputation: 19213

Rails: How can I define one-to-many relationships using the rails "generate" script?

I'd like to run the rails "generate" script and create a model that belongs two other models. Is there a way that I can do this?

Upvotes: 3

Views: 853

Answers (1)

Drew Johnson
Drew Johnson

Reputation: 19213

Figured it out. If you have a model named "child" that belongs to a model named "mom" and a model named "dad", the syntax is:

rails generate model child mom:reference dad:reference

Upvotes: 4

Related Questions