Forum: Ruby on Rails Rails multistep form with ajax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
59137fc8c8ac1ab935e0919fbfe0201c?d=identicon&s=25 Seth Portman (Guest)
on 2013-08-02 14:01
(Received via mailing list)
I am following Railscasts #217 and I have been able to make everything
work
using html protocol the only issue is that I need it to use ajax
protocol
instead. My question and code is very similar to stackoverflow question
Multistep
forms in Rails using
AJAX<http://stackoverflow.com/questions/14228368/multis...
.
I understand how to setup ajax and make the form sumit remotely my
question
though is how do I pass over the forms variable i.e. "f" as in "<%=
form_for @post do |f|>" Any help is appreciated.

Originally asked at
http://stackoverflow.com/questions/18001406/rails-...
280b78a61a968391b7e07e912be102a8?d=identicon&s=25 Robert Walker (robert4723)
on 2013-08-02 16:03
Seth Portman wrote in post #1117487:
> I am following Railscasts #217 and I have been able to make everything
> work
> using html protocol the only issue is that I need it to use ajax
> protocol
> instead. My question and code is very similar to stackoverflow question
> Multistep
> forms in Rails using
>
AJAX<http://stackoverflow.com/questions/14228368/multis...
> .
> I understand how to setup ajax and make the form sumit remotely my
> question
> though is how do I pass over the forms variable i.e. "f" as in "<%=
> form_for @post do |f|>" Any help is appreciated.

I think you're probably making this too complicated. If you're using
JavaScript anyway then just have one page, with one form. Use JavaScript
(no AJAX required) to show and hide the fields for the various steps in
the process. Ryan mentioned, and recommended, this approach at the
beginning of the episode.

Since have have only a single page with a single form there's nothing to
pass around. The are no changes required in your controller or model
classes. As far as Rails is concerned it's no different than a regular
form submission.

If your multi-step form is extremely complex then I might suggest
considering one of the single page app solutions such as Ember.js,
Backbone.js or Angular.js.
This topic is locked and can not be replied to.