Rails‎ > ‎

Rails - How to define "OneToMany "

In order to define a "oneToMany" relationship between objects in Rails you should do the following steps :
  1. add "belongs_to :id" on the "many" object
  2. add "has_many :id" on the "one" object
  3. go to "migrations" file and add a line : "CONSTRAINT fk_many_one REFERENCES one(id)"
Comments