title: bootstrap modal for edit user profile
body: <p><a href="https://i.stack.imgur.com/eDdA8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eDdA8.jpg" alt="enter image description here"></a>I have added bootstrap modal to edit user profile. It edits user profile but when there is an error in the form content  it redirects to localhost:3000/user .how can I get errors in the modal itself? I used devise  gem for user. what did I do wrong</p>
  
  <p><strong>_edit.html.erb</strong> </p>
  
  <pre><code>&lt;div class="modal" id="EditProfileModal" data-keyboard="false" data-backdrop="static" tabindex="-1" role="dialog"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
            &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
          &lt;h4 class="modal-title"&gt;Edit user&lt;/h4&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;div class="container"&gt;
            &lt;%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %&gt;
                &lt;%= devise_error_messages! %&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.label :email %&gt;&lt;br/&gt;
                  &lt;%= f.email_field :email, autofocus: true, :value =&gt; current_user.email %&gt;
                &lt;/div&gt;
  
                &lt;% if devise_mapping.confirmable? &amp;&amp; resource.pending_reconfirmation? %&gt;
                    &lt;div&gt;Currently waiting confirmation for: &lt;%= resource.unconfirmed_email %&gt;&lt;/div&gt;
                &lt;% end %&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.label :password %&gt; &lt;i&gt;(leave blank if you don't want to change it)&lt;/i&gt;&lt;br/&gt;
                  &lt;%= f.password_field :password, autocomplete: "off" %&gt;
                  &lt;% if @minimum_password_length %&gt;
                      &lt;br/&gt;
                      &lt;em&gt;&lt;%= @minimum_password_length %&gt; characters minimum&lt;/em&gt;
                  &lt;% end %&gt;
                &lt;/div&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.label :password_confirmation %&gt;&lt;br/&gt;
                  &lt;%= f.password_field :password_confirmation, autocomplete: "off" %&gt;
                &lt;/div&gt;
  
                &lt;div class="form-group"&gt;
                  &lt;%= f.label :current_password %&gt; &lt;i&gt;(we need your current password to confirm your changes)&lt;/i&gt;&lt;br/&gt;
                  &lt;%= f.password_field :current_password, autocomplete: "off" %&gt;
                &lt;/div&gt;
  
                &lt;div class="actions"&gt;
                  &lt;%= f.submit "Update" %&gt;
                &lt;/div&gt;
            &lt;% end %&gt;
  
            &lt;h3&gt;Cancel my account&lt;/h3&gt;
  
            &lt;p&gt;Unhappy? &lt;%= button_to "Cancel my account", registration_path(resource_name), data: {confirm: "Are you sure?"}, method: :delete %&gt;&lt;/p&gt;
  
          &lt;/div&gt;
        &lt;/div&gt;
  
        &lt;div class="modal-footer"&gt;
        &lt;/div&gt;
      &lt;/div&gt;&lt;!-- /.modal-content --&gt;
    &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
  &lt;/div&gt;&lt;!-- /.modal --&gt;
  </code></pre>
  
  <p><strong>header</strong></p>
  
  <pre><code>&lt;% if user_signed_in? %&gt;
      &lt;header&gt;
        &lt;%= link_to "sign out", destroy_user_session_path, method: :delete %&gt;&amp;nbsp;&amp;nbsp;
        &lt;%= link_to "Edit profile", '#EditProfileModal', {'data-toggle' =&gt;  "modal"} %&gt;
        &lt;div style="text-align: center"&gt;Signed in as &lt;b&gt;&lt;%= current_user.email %&gt;&lt;/b&gt;&lt;/div&gt;
      &lt;/header&gt;
      &lt;%= render "devise/registrations/edit"%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/eDdA8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eDdA8.jpg" alt="**Log**"></a></p>