On Dec 20, 3:53 am, Colin Law <clan...@googlemail.com> wrote:
> On 20 December 2011 07:03, Bob Smith <bsm...@gmail.com> 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.
>
> Colin

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.

Bob

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to