Rails3: form_tag remote option doesn't work as expected

109 Views Asked by At

I want to do the following :

capture an e-mail address in a field through a form_tag helper fire the corresponding controller to:

  1. store it in a table
  2. send an e-mail to that address
  3. show a confirmation message

I use a partial for the form_tag:

_confirmation.html.erb

  <%= form_tag(confirmation_path, remote: true) do %>
    Please enter your e_mail address : <%= text_field_tag 'email' %><button class="btn btn-primary" type="submit"</button>
  <% end %>

confirmation_path points to route captmails#confirmation via POST.

When I run the page with the partial and I submit the e-mail address, it is wrongly looking for the template captmails/confirmation, ie the HTML template, which doesn't exist, since what I want to do a remote call to the corresponding captmails/confirmation.js.erb template, ie Javascript template, which is well there.

So it is like it doesn't take the 'remote: true' parameter into account. Is there another way to do the same?

0

There are 0 best solutions below