Forum: Ruby on Rails Complex Database Associations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mike Kelland (Guest)
on 2006-04-23 20:20
(Received via mailing list)
Hi All,

I'm running into some issues with a fairly complex database structure.

I have 4  tables:
- id
- name

- id
- product_id
- name

- id
- product_id
- serialnumber

- id
- productsitem_id
- unit_id
- partnumber
- serialnumber

What I'm attempting to do is to create a page where, after selecting
which product I'm entering, I get presented with the data entry for a
new unit and the appropriate number of unitparts for that product as
defined by productsitems.  The issue is that I need to somehow, in the
view, link the partnumber and serialnumber fields back to the
appropriate productsitem and then to parse them out so that those ids
make it into the database.

In other languages I would simply enumerate my fields and parse the
resulting variable names - is there a simple way to do this in Rails?

This topic is locked and can not be replied to.