Forum: Ruby on Rails Not sure where to begin updating a child table

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
a.filipowski (Guest)
on 2005-11-22 22:12
(Received via mailing list)
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.


a.filipowski (Guest)
on 2005-11-22 22:56
(Received via mailing list)
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_#{}"
			@temp = params[value_text]
     		@value.update_attribute(:value_text => @temp)
		# more stuff here


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 => }) %>
			<%= text_area_tag(:field_text, @field.field_text) %><br/><br/>
			<div id="Values<%= h( %>">
				<% for @value in @field.values %>
					<div id="Value<%= h( %>">
	<input type="text" name="valuetext_<%= h( %>" value="<%= h
(@value.value_text) %>">
			<% 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.

Jm M. (Guest)
on 2005-11-22 23:08
(Received via mailing list)
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
vanek (Guest)
on 2005-11-23 16:17
(Received via mailing list)
<%= stylesheet_link_tag "your_css_stylesheet" %>
This topic is locked and can not be replied to.