Rails: How can I define a one-to-many relationship using the “generate” script rails?

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

+3
source share
1 answer

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

rails generate model child mom:reference dad:reference
+4
source

Source: https://habr.com/ru/post/1741515/


All Articles