I am new to Rails and have struggled with this problem for many hours - I will be very grateful for any help.
I have a registration form (using Devise and simple_form) inside the Bootstrap modal module and would like error notifications to be displayed in the same modal format when the form was submitted. Currently, when a form is submitted with errors, the page redirects / to users and errors are displayed there. When the form is submitted without errors, the page remains on the home page and displays a โsuccessfulโ flash message as desired.
I donโt know if this problem is caused by the controller / routing problem, do I need to (first find out) add jQuery / Javascript / Ajax or something else.
Modal code (contained in partial)
<div id="signupModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="signupLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">ร</button> <h3 id="signupLabel">Sign up</h3> </div> <div class="modal-body"> <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: "form-horizontal"}) do |f| %> <%= f.error_notification %> <%= f.input :name, placeholder: 'John Smith', input_html: {class: 'span7'} %> ... <div class="form-actions"> <%= f.submit "Sign up", class: "btn btn-large btn-success" %> </div> <% end %> </div> </div>
application_helper.rb - this code was added after reading this SO question
module ApplicationHelper def resource_name :user end def resource @resource ||= User.new end def devise_mapping @devise_mapping ||= Devise.mappings[:user] end end
source share