Okay, so I want to use the twitter bootstrap modal to display the devise sign-in form.
I am basing my code of the wiki article here: https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
I have the below markup in my application layout file
<div class="modal fade" id="loginModal">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Sign In</h3>
</div>
<div class="modal-body">
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => 'form-horizontal'}) do |f| %>
<div class="inputs">
<%= f.input :email, :required => false, :autofocus => true %>
<%= f.input :password, :required => false %>
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
</div>
</div>
<div class="modal-footer">
<%= f.button :submit, "Sign in", :class => 'btn btn-primary', :data => { :dismiss => "modal"} %>
<% end %>
</div>
</div>
And, following the advice in the wiki, added the following to the application helper file
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
It however, does not work. The modal dismisses and nothing happens. The page doesn't go anywhere or do anything. Going to the actual sign-in page works, but submitted the modal does not. Suggestions?
This is the code that ended up working
<%= simple_form_for(:user, :url => user_session_path) do |f| %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With