-
Notifications
You must be signed in to change notification settings - Fork 5.5k
How To: Display a custom sign_in form anywhere in your app
styledev edited this page Mar 20, 2011
·
13 revisions
It’s easy to create a custom login form that can be used anywhere in your application.
Here’s an example in HAML:
= form_tag new_user_session_path do
= text_field_tag 'user[email]'
= password_field_tag 'user[password]'
= check_box_tag 'user[remember_me]'
= label_tag 'user[remember_me]', 'Remember me'
%button Login
= link_to "Forgot your password?", new_password_path('user')
Another example with form_for and posting to user_session_path:
<%= form_for("user", :url => user_session_path) do |f| %>
<%= f.text_field :email %>
<%= f.password_field :password %>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<%= f.submit 'Sign in' %>
<%= link_to "Forgot your password?", new_password_path('user') %>
<% end %>
Note: “user” in this context is the resource you specified when setting up Devise.