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?

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

Ahhh, that you for showing me the scheme. Where is this documented?

It is documented indirectly here

http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

-Daniel