On Dec 20, 3:53 am, Colin Law wrote:
On 20 December 2011 07:03, Bob Smith wrote:

I'm doing a list of family members, each with aradiobutton for head
of household. After the household record and the records for each
person are created, it is easy to set the hoh field to the person
wanted. The problem comes if I try to set this field before the
create. Then the field is 0, and this isn't updated after the record
is created.
Show us how you are setting the field, presumably increatein the controller.

I was using a variable called hoh in the household (master) record.
This was holding the id number of the person (child) record selected.
This worked fine for existing records, but got lost with records
created at the time of the save, as these records had no id yet.

Someone else suggested that I put the hoh variable in the person
records, but if I do this, each radio button is separate, and there is
no way to allow only one selection.

It seems to me that there must be a way to do this with Active Record
Callbacks. After the record is created, it has an id. Couldn't I test
each person record after create, and if it has the radio button
selected, pass the id to the Household.hoh variable..

But for this... Is there a way to tell if the radio button is selected
if it points to a variable somewhere else ?? Or is there a way to get
Rails to just do this at the right time the way it does with parent/
child records, setting all id's and parent_id's ??

Too many question marks.


You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 11 | next ›
Discussion Overview
grouprubyonrails-talk @
postedDec 20, '11 at 7:04a
activeJan 17, '12 at 5:48a



site design / logo © 2022 Grokbase