Hi, Is there a simpler way to implement the view-component of nested forms as it was done in Railscast #75 (Complex Forms Part 3) in Rails 2.3? I''d like to add and remove the owned objects dynamically using AJAX requests, but using f.fields_for :object do |object_form| doen''t let me load new objects into the form - or at least I don''t fully understand how that should work. Should I use fileds_for :object, iterator do |object_form instead? Does anyone know a simple example for this kind of usage on the web? Thanks for any advice! Best regards --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 16, 12:32 pm, tilt <breuer.t...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I''d like to add and remove the owned objects dynamically using AJAX > requests, but using f.fields_for :object do |object_form| doen''t let > me load new objects into the form - or at least I don''t fully > understand how that should work. > > Should I use fileds_for :object, iterator do |object_form instead? > Does anyone know a simple example for this kind of usage on the web?I''m not sure exactly which bit you are stuck at but any modifications to the object association should be represented by fields_for. As one way you can get a new object template is to simply build a blank one on the collection, e.g: @parent = Parent.find(..) @parent.assoc_objects.build form_for @parent... do |f| f.fields_for :assoc_objects do.. # Will have ''empty'' here Hope that helps. Andrew --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Hi, Thanks for your answer! Sorry, I mixed some things up in my question above. I''d like the associated objects to be chosen from a select box using collection_select. The request data submitted to update the associated objects is: object=>{ ... "associated_object_attributes"=>{"0"=>{"_delete"=>"0", "id"=>"1"}, "1"=>{"_delete"=>"0", "id"=>"3"}, "2"=>{"id"=>"3"}} } So only the IDs are submitted. I seemingly have to handle this in the controller by myself because the other data of the associated objects is missing. If I''m wrong I''d be very thankful if someone corrected me. Best regards --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- 2.3 Nested Model Forms; build new without updating existing
- Rails 3 - Nested Forms, using Builder -- Check_box issue
- accepts_nested_attributes_for with has_many => :through
- Best way to instanciate an empty address element in many nested fields_for
- Nested Forms - how to displayed the attributes content ?