Not sure where to begin updating a child table


#1

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.

Thanks

Andrew


#2

To clarify here is some code that I have tried:

My controller has this action:

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)

<%= form_remote_tag( :update => ‘FieldDesignArea’,
:url => { :action => ‘update_radio_buttons’, :id =>
@field.id }) %>
Field:

<%= text_area_tag(:field_text, @field.field_text) %>


Values:


<% for @value in @field.values %>

<% end %>

The error that I get when I run this code after making a change is
the following:

wrong number of arguments (1 for 2)

and the parameters look like this:

Parameters: {“commit”=>“Udate”, “valuetext_58”=>“huh”,
“valuetext_71”=>“Choice”, “id”=>“106”, “required”=>“1”, “_”=>"",
“field_text”=>“New Field Is here”}

So that is in a nut shell what I am trying to do. Any help would be
greatly appreciated.

Andrew


#3

I copied a directory of views and noticed that the
Scaffold.CSS stylesheet didn’t add to my pages. Is
there a way to manually link to a style sheet?


Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com


#4

<%= stylesheet_link_tag “your_css_stylesheet” %>