Rails: Ajax-enabled form without a model object

Posted by Caffeine Coma on Stack Overflow See other posts from Stack Overflow or by Caffeine Coma
Published on 2012-06-09T23:49:10Z Indexed on 2012/06/10 4:40 UTC
Read the original article Hit count: 218

Filed under:
|

I'm new to Rails and having a hard time figuring out how to create a form that submits over Ajax without having a corresponding model object.

My use case is a simple form that collects an email address and sends it an email; there's nothing to be persisted, so no model.

In cases where I do have a model, I've had success with form_for(@model, remote: true). I can't seem to find the right helper for the case where there is no model. I tried form_tag(named_path, remote: true) and that works, but does not use Ajax.

Pointers to an example with an example with a proper controller, .html.erb and routes.rb would be really appreciated.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails-3