Rails: Relate two records after creation -
i have model in rails:
class commission < activerecord::base has_and_belongs_to_many :books end class book < activerecord::base has_and_belongs_to_many :commissions end
this model generates 3 tables: commission, book , books_commissions. in first process of app generate , save commissions , books without relating entries.
question: how create record in books_commissions if know book_id , commission_id?
lets have object book
model book , object commission
model commission.
then book.commissions << commission
should trick.
Comments
Post a Comment