Please how can I save more than one field ?

I have Product has many colors by quantity.

This works
#controller: products  action: new file:_form.erb
                <% for color in Color.all %>
                        <div>
                                <%= check_box_tag "product[color_ids][]", 
color.id,
@product.colors.include?(color) %>
                        <%= color.name %>
                        </div>
                <% end %>

but if I add one more field the value will not work.

<%= text_field_tag "stock["+color.id.to_s+"][qtd]" %>

Please anyone can help me?

My structure:

class Product < ActiveRecord::Base
  has_many :stocks, :dependent => :destroy
  has_many :colors, :through => :stocks
end

class Color < ActiveRecord::Base
  has_many :stocks
  has_many :product, :through => :stocks
end

class Stock < ActiveRecord::Base
  belongs_to :product
  belongs_to :color
end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to