Updating multiple records in form

Hi. I have an app that has prodcts, which have many details.

I’m writing a view that allows the user to update the product info and
also info on each details record (number remaining in inventory, etc).
The form displays fine and populates w/ the detail records, and it
updates the product record. But it does not alter the detail record at
all. Suggestions?

Here’s the controller…

def edit
	if request.get?
  		@product = Product.find(params[:id], :order=>'gender, size',

:include=>‘details’ )

		@product = product.find(params[:id])
		if @product.update_attributes(params[:product])
  			flash[:notice] = 'product was successfully updated.'
  			redirect_to :action => 'show', :id => @product
  			render :action => 'edit'

And a snippet of the view

<% for @detail in @product.details %>

<%= text_field ("detail[]", "remaining") %> <% end %>

It looks like you’re wanting @product.update to automatically alter the
associated record based on the contents of params.

As far as I know, rails won’t do this out of the box. - You’ll have to
do it manually, either in the controller or the model.

Cheers -

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs