Devise Custom Routes and Login Pages Devise Custom Routes and Login Pages ruby ruby

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' %>


The following worked for me:

  devise_for :users do    get "/login" => "devise/sessions#new"    get "/register" => "devise/registrations#new"  end


You just need don't put your special route in devise_for block

match '/dashboard' => 'home#dashboard', :as => 'user_root'get "/login", :to => "devise/sessions#new" # Add a custom sign in route for user sign inget "/logout", :to => "devise/sessions#destroy" # Add a custom sing out route for user sign outget "/register", :to => "devise/registrations#new" # Add a Custom Route for Registrationsdevise_for :user

Now /login works. /users/sign_in too.