eggie5
2007-Aug-23 05:13 UTC
Formatting form post to work with MyClass.new(params[:my_class])
So, In my html page I have a simple (non rails generated) html for that posts to the server via an ajax call using prototype''s form.serialize. It used to post to an asp.net page, but now I want it to post to my rails controller. This is what I have: @my_class = MyClass.new(params[:my_class]) I don''t want to have to set each property of MyClass one-by-one, I want to do what the above code shows. I want to pass all the necessary values to the MyClass constructor. How can I translate my html form values to do this? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel N
2007-Aug-23 05:17 UTC
Re: Formatting form post to work with MyClass.new(params[:my_class])
On 8/23/07, eggie5 <eggie5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > So, > > In my html page I have a simple (non rails generated) html for that > posts to the server via an ajax call using prototype''s form.serialize. > It used to post to an asp.net page, but now I want it to post to my > rails controller. This is what I have: > > @my_class = MyClass.new(params[:my_class]) > > I don''t want to have to set each property of MyClass one-by-one, I > want to do what the above code shows. I want to pass all the necessary > values to the MyClass constructor. > > How can I translate my html form values to do this?For it do do this your form inputs need to be named name="mycalss[fieldname]" Then it will work like you want. If you can''t have everything named like that, you''ll need to do it manually. HTH Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
eggie5
2007-Aug-23 05:37 UTC
Re: Formatting form post to work with MyClass.new(params[:my_class])
Ahhh, that you for showing me the scheme. Where is this documented? On Aug 22, 10:17 pm, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 8/23/07, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > So, > > > In my html page I have a simple (non rails generated) html for that > > posts to the server via an ajax call using prototype''s form.serialize. > > It used to post to an asp.net page, but now I want it to post to my > > rails controller. This is what I have: > > > @my_class = MyClass.new(params[:my_class]) > > > I don''t want to have to set each property of MyClass one-by-one, I > > want to do what the above code shows. I want to pass all the necessary > > values to the MyClass constructor. > > > How can I translate my html form values to do this? > > For it do do this your form inputs need to be named > > name="mycalss[fieldname]" > > Then it will work like you want. If you can''t have everything named like > that, you''ll need to do it manually. > > HTH > Daniel--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daniel N
2007-Aug-23 05:45 UTC
Re: Formatting form post to work with MyClass.new(params[:my_class])
On 8/23/07, eggie5 <eggie5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Ahhh, that you for showing me the scheme. Where is this documented? > > On Aug 22, 10:17 pm, "Daniel N" <has....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 8/23/07, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > > > > So, > > > > > In my html page I have a simple (non rails generated) html for that > > > posts to the server via an ajax call using prototype''s form.serialize. > > > It used to post to an asp.net page, but now I want it to post to my > > > rails controller. This is what I have: > > > > > @my_class = MyClass.new(params[:my_class]) > > > > > I don''t want to have to set each property of MyClass one-by-one, I > > > want to do what the above code shows. I want to pass all the necessary > > > values to the MyClass constructor. > > > > > How can I translate my html form values to do this? > > > > For it do do this your form inputs need to be named > > > > name="mycalss[fieldname]" > > > > Then it will work like you want. If you can''t have everything named > like > > that, you''ll need to do it manually. > > > > HTH > > DanielIt is documented indirectly here http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html -Daniel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---