Justin
is to put the parent object’s ID in the URL parameter
I know, and that’s what I do, but it’s not nice.
OK - your previous post said that you were using a hidden field.
I’ve tried many techniques, where I each time explicitely manipulated
the belonged_to/foreign_key related object/id.
3/collect the parts + the foreign keys id, and then
4/ fetch the foreign object and rebuild the main object
before 5/saving.
Your earlier question was just about members of projects
Actually, I’m letting one member edit his info, but the project is fixed
in advance.
member = Member.new (:project => the_project)
Which relationships are genuine “belongs to” (strict containment)
relationships, and which are just references?
For example, add a new ‘Employee’ to a a given ‘Company’, and give him a
default work “Address”.
=> The data sent to the form is
e = Employe.new (:company => the_company, :address =>
the_company.address)
In the db, the ‘employees’ table has 2 foreign keys : company_id, and
address_id.
My problem is that when it comes to creating an ‘employee’ in a form, I
have to EXPLICITELY manipulate its ‘address’ and ‘company’ ids/foreign
keys after the submit, even though I already set those 2 values in an
earlier step (see above).
( manipulate the fk == extract them, send them to the form, store them
in hidden fields as numerical values, and after the submit perform
multiple XXX.find( fk) to retrieve the employee previously known address
and company, and stuff them back in the employee object.
I’m just wondering/asking is there is a Rails idiom for this case, that
would make my life simpler and the code shorter/clearer.
Alain