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
Andrew Filipowski
2005-Nov-22  20:55 UTC
Re: Not sure where to begin updating a child table
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:<br/>
			<%= text_area_tag(:field_text, @field.field_text)
%><br/><br/>
			Values:<br/>
			<div id="Values<%= h(@value.id) %>">
				<% for @value in @field.values %>
					<div id="Value<%= h(@value.id) %>">
	<input type="text" name="valuetext_<%= h(@value.id)
%>" value="<%= h
(@value.value_text) %>">
</div>
			<% end %>
			</div>
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
On Nov 22, 2005, at 3:11 PM, Andrew Filipowski wrote:
> 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
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
jonathan Mcintire
2005-Nov-22  21:04 UTC
Easy Question : Linking to CSS from view/.rthml files
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
<%= stylesheet_link_tag "your_css_stylesheet" %> jonathan Mcintire wrote:> 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?