0
votes

I have a sign up form (Simple Form):

    <%= simple_form_for(User.new, as: 'user', url: registration_path('user'), html: {id: "signup-form"},:remote => true) do |f| %>
              <input name="redirect_to" type="hidden" value="true"/>
              <%= f.input :first_name, required: true, autofocus: true, placeholder: "First Name", label: false %>
              <%= f.input :last_name, required: true, autofocus: true, placeholder: "Last Name", label: false %>
              <%= f.input :email, required: true, autofocus: true, placeholder: "E-mail Address" %>
              <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable), placeholder: "Password" %>
              <%= f.input :password_confirmation, required: true, placeholder: "Password Again" %>
              <%= f.submit "Sign up", class: "btn btn-primary btn-lg btn-block", data: { target: "#confirm-modal", toggle: "modal", dismiss: "modal" }%>
<% end %>

When a user clicks on submit the form should do an Ajax POST to Devise::RegistrationsController create action and then show another modal data-target="#confirm-modal". The issue here is that it is not submitting any post request. Is there a specific configuration with Simple Form for this ?

1
This is one way of doing it: stackoverflow.com/a/17266384/1438462 - Lucas Moulin
@Cyzanfar: I suggest you to have a look on this tutorial which will guide you to understand how modals works in Rails, so that you can master it : richonrails.com/articles/basic-ajax-in-ruby-on-rails - Praveen George
@Cyzanfar, Personally never tried to use devise calling it asynchronously. Did you try without :remote => true ? If it works, then you need to rewrite Create method from Devise::RegistrationsController. - 7urkm3n

1 Answers

1
votes

Edit: For posterity's sake, I'm editing this with what fixed the issue.

The issue is from the data parameter being passed into the submit button. Removing it will allow the AJAX request to be sent.