I have a table that is defined as has_many and the child table is
defined as has_one. I can create new children with ease and do almost
everything else I want to do with it except for one thing. I have a
form and within that form I have text boxes to update a column in the
the children objects (multiple). In that same form I want to also
update columns and attributes of the parent. Does anyone have an
example to have a single button form that updates multiple tables/
models? Or can you point me to the right tutorial? Agile Web
Development mentions passing an array to the update method but there
is no example.
def update_radio_buttons @field = Field.find(params[:id]) @field.update_attributes(:field_text => params[:field_text],
:required => params[:required])
for @value in @field.values
value_text = “:valuetext_#{@value.id}” @temp = params[value_text] @value.update_attribute(:value_text => @temp)
end
# more stuff here
end
view:
my view looks sort of like this (i condensed the partials and some of
the other stuff going on on the page to save some space here)