更新时间:2022-12-11 18:27:17
对于Devise 1.1.3,以下内容应该是
With Devise 1.1.3 the following should work
devise_for :user, :path => '', :path_names => { :sign_in => "login", :sign_out => "logout", :sign_up => "register" }
它创建的路由不会附加/ user / ...因为:path
参数是一个空字符串。 :pathnames
哈希将根据您喜欢的路由命名。 Devise将内部使用这些路由,因此提交到/ login将按照您的意愿工作,而不会将您带到/ user / log_in
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
要将登录表单添加到您的首页, Devise Wiki的信息:
http://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
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
或者做这样的事情:
<%= form_tag new_user_session_path do %>
<%= text_field_tag 'user[email]' %>
<%= password_field_tag 'user[password]' %>
<%= submit_tag 'Login' %>