Devise Custom Routes and Login Pages

后端 未结 6 1344
北荒
北荒 2020-11-30 23:12

I\'m trying to get Custom Routes working in my Rails application (Ruby 1.9.2 with Rails 3).

This is my config/routes.rb file

match \'/dashboard\' =&g         


        
6条回答
  •  清歌不尽
    2020-11-30 23:50

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

提交回复
热议问题