how to add a entry to tables with relationships?
Posted
by siulamvictor
on Stack Overflow
See other posts from Stack Overflow
or by siulamvictor
Published on 2010-05-07T02:58:53Z
Indexed on
2010/05/07
3:18 UTC
Read the original article
Hit count: 319
I have 2 models, Users & Accounts. They are in one-to-many relationship, i.e. each accounts have many users.
Accounts
company_id company_name company_website
Users
user_id user_name password company_id email
How can I add these entries to database using ActiveRecord? Supposed I don't is the company existed in the database when I add a new entry.
Name Email Password Company
-----------------------------------------------------------------------------
Albert [email protected] 123456 ABC Company
Betty [email protected] 234567 ABC Company
Carmen [email protected] 765432 XXX Company
David [email protected] 654321 ABC Company
© Stack Overflow or respective owner