Devise Custom Routes and Login Pages

With Devise 1.1.3 the following should work

devise_for :user, :path => '', :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" }

The routes it creates will not be appended with “/user/…” because of the :path parameter being an empty string. The :pathnames hash will take care of naming the routes as you like. Devise will use these routes internally so submitting to /login will work as you wish and not take you to /user/log_in

To add a login form to your front page there’s info at the Devise Wiki:
http://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

Or do something like this:

 <%= form_tag new_user_session_path do %>
  <%= text_field_tag 'user[email]' %>
  <%= password_field_tag 'user[password]' %>
 <%=  submit_tag 'Login' %>

Leave a Comment