hi, I just try to deal with multiples model in one form, using ajax to add models. but got a weird params hash. got: :master_model => { :sub_model => [ { :field_1 => "1" }, { :field_1 => "2", :field_2 => "3" }, { :field_2 => "4" } ] } instead of : :master_model => { :sub_model => [ { :field_1 => "1" :field_2 => "3" }, { :field_1 => "2", :field_2 => "4" } ] } anybody can help me? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
i just checked it again and it looks like a form_remote_for bug, because with a non ajax form_for params are well formed, can someone confirm it? On 20 sep, 18:36, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, > > I just try to deal with multiples model in one form, > using ajax to add models. but got a weird params hash. > > got: > :master_model => { > :sub_model => [ > { :field_1 => "1" }, > { :field_1 => "2", :field_2 => "3" }, > { :field_2 => "4" } > ] > > } > > instead of : > > :master_model => { > :sub_model => [ > { :field_1 => "1" :field_2 => "3" }, > { :field_1 => "2", :field_2 => "4" } > ] > > } > > anybody can help me?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Sep 22, 1:29 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i just checked it again and it looks like a form_remote_for bug, > because with a non ajax form_for params are well formed, > can someone confirm it?It''s impossible to confirm with the little information you''ve given. Care to elaborate? --~--~---------~--~----~------------~-------~--~----~ 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 erol, Try this : <% form_for(@master_model) do |f| %> <%= f.error_messages %> <%- fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - %> <%= sm.text_field :field1 %> <%= sm.text_field :field2 %> <%= sm.text_field :field3 %> <%- end -%> <%- fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - %> <%= sm.text_field :field1 %> <%= sm.text_field :field2 %> <%= sm.text_field :field3 %> <%- end -%> <p> <%= f.submit "Create" %> </p> <% end %> then check params format (it should be ok), then replace "form_for" with "remote_form_for" and check params format, "master_model[sub_model]" should be wrong On 22 sep, 01:29, Erol Fornoles <erol.forno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sep 22, 1:29 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i just checked it again and it looks like a form_remote_for bug, > > because with a non ajax form_for params are well formed, > > can someone confirm it? > > It''s impossible to confirm with the little information you''ve given. > Care to elaborate?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I am having this same problem, but I need to do this with ajax..... any ideas? I''ve been racking my brain on this for a few hours now and am losing it, On Sep 22, 6:47 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi erol, > > Try this : > > <% form_for(@master_model) do |f| %> > <%= f.error_messages %> > > <%-fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - > %> > <%= sm.text_field :field1 %> > <%= sm.text_field :field2 %> > <%= sm.text_field :field3 %> > <%- end -%> > > <%-fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - > %> > <%= sm.text_field :field1 %> > <%= sm.text_field :field2 %> > <%= sm.text_field :field3 %> > <%- end -%> > <p> > <%= f.submit "Create" %> > </p> > <% end %> > > then check params format (it should be ok), then replace "form_for" > with "remote_form_for" and check params format, > "master_model[sub_model]" should be wrong > > On 22 sep, 01:29, Erol Fornoles <erol.forno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Sep 22, 1:29 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > i just checked it again and it looks like a form_remote_for bug, > > > because with a non ajax form_for params are well formed, > > > can someone confirm it? > > > It''s impossible to confirm with the little information you''ve given. > > Care to elaborate?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Thu, 2008-09-25 at 12:11 -0700, Nathan R wrote:> I am having this same problem, but I need to do this with ajax..... > any ideas? I''ve been racking my brain on this for a few hours now and > am losing it, > > On Sep 22, 6:47 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi erol, > > > > Try this : > > > > <% form_for(@master_model) do |f| %> > > <%= f.error_messages %> > > > > <%-fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - > > %> > > <%= sm.text_field :field1 %> > > <%= sm.text_field :field2 %> > > <%= sm.text_field :field3 %> > > <%- end -%>I find way better results with form_remote_for([@master_model, @sub_model]) in cases where I need several instances of sub model I do something like this in the view <% unless @master_model.sub_models.nil? %> <%= render :partial => ''sub_model'', :collection => @master_model.sub_models, :object => @master_model%> <% end %> <%= render :partial => ''new_sub_model'', :object => [@master_model, @sub_model] %> then the partials use div_for(sub_model) so the controller can talk back ajax to each instance of the form the new_sub_model partial sends to create, then create via rjs, refreshes the list of sub_models and shows a new empty new_sub_model template> > > > <%-fields_for(''master_model[sub_model][]'', SubModel.new) do |sm| - > > %> > > <%= sm.text_field :field1 %> > > <%= sm.text_field :field2 %> > > <%= sm.text_field :field3 %> > > <%- end -%> > > <p> > > <%= f.submit "Create" %> > > </p> > > <% end %> > > > > then check params format (it should be ok), then replace "form_for" > > with "remote_form_for" and check params format, > > "master_model[sub_model]" should be wrong > > > > On 22 sep, 01:29, Erol Fornoles <erol.forno...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Sep 22, 1:29 am, jney <jeansebastien....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > i just checked it again and it looks like a form_remote_for bug, > > > > because with a non ajax form_for params are well formed, > > > > can someone confirm it? > > > > > It''s impossible to confirm with the little information you''ve given. > > > Care to elaborate? > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- >-- Andres Paglayan CTO, StoneSoup LLC Ph: 505 629-4344 Mb: 505 690-2871 FWD: 65-5587 Testi. Codi. Vinci.