Hello, 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| .block .column.span-12 = 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? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 July 2011 10:21, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > 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| > .block > .column.span-12 > = 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? >Any advice? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe Matching Threads
- Simple_Form and Simple_Fields_For and working in Form_Tag, Fields_For
- Form Design issue - How to handle a parent association input..
- How do I force link_to/form helpers to use the superclass name in the path instead subclass?
- how to get the index of the element passed to the render view ?
- set a default value with simple_form