ruby on rails - generating model with ActiveRecord associations -
folks,
i working on creating application have 2 entities in problem space. 1 entity "biologist" , other entity "experiment" 1 biologist can have many experiments , each experiment can have many biologist.
i know how create models , routes using command line generator:
rails generate scaffold biologist name:string expertise:string last_pub:text
what right way add together association? go , update model code after generation? unclear me if add together "belongs_to" association post generation how reflect in db schema without running migration or something? in above illustration if "experiment" belongs "biologist" there foreign key in "biologist" table, how created if add together associations in model class post generation. new rails, apologize if naive question.
you have create migration add together biologist_id
column experiments
table, , add together belongs_to :biologist
relationship in experiments
model.
you can find more details here.
ruby-on-rails rails-activerecord
No comments:
Post a Comment