Skip to content

How To: Display a custom sign_in form anywhere in your app

florent edited this page Feb 9, 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]'
  %button Login

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.submit 'Sign in' %>
<% end %>

Note: “user” in this context is the resource you specified when setting up Devise.

Clone this wiki locally