Saturday, 14 September 2013

Adding object with several sub-objects at once

Adding object with several sub-objects at once

Let's say I have following database:
Company (name, sector) has many Products (name, price)
I would like users of my Rails website to be able to add new companies
along with their products. So the form would look like:
Add new company
--------------------
Name: [ ]
Sector: [ ]
Product 1:
Name [ ]
Price [ ]
Product 2:
Name [ ]
Price [ ]
Product 3:
Name [ ]
Price [ ]
Ideally users would be able to add as many products at once as required
(auto expanding list?). How can I program that in Rails?

No comments:

Post a Comment