3 models in a form


class Customer < ActiveRecord::Base
has_many :deliveries

class Delivery < ActiveRecord::Base
has_many :delivery_items
has_many :products, :through => :delivery_items
belongs_to :customer

class DeliveryItem < ActiveRecord::Base
belongs_to :delivery
belongs_to :product

I create a new delivery for customer x:

= simple_form_for @customer do |f|
= f.simple_fields_for :deliveries do |deliveries_f|
= deliveries_f.association :products, :multiple => true,
:selected => @products_selected_id,
:input_html => { :title => “-
Select product -” }, :label => false
= deliveries_f.input :notes

DeliveryItem has the extra attribute quantity.
In this form I have to set a quantity DeliveryItem attribute so that I
create a Delivery for customer x, associate one or more Product and
for a product set the quantity.
How can I do in the form?

On 25 July 2011 10:21, Mauro [email protected] wrote:

class DeliveryItem < ActiveRecord::Base
:selected => @products_selected_id,

Any advice?