我使用 devise for rails 3.2 进行身份验证。我已将默认路由从设计更改为:
devise_scope :user do
get 'signin' => 'devise/sessions#new', :as => :new_user_session
post 'signin' => 'devise/sessions#create', :as => :user_session
match 'signout' => 'devise/sessions#destroy', :as => :destroy_user_session,
:via => Devise.mappings[:user].sign_out_via
end
现在我的登录和注册表单在根站点上。如何避免访问 127.0.0.1:3000/signin 但在删除它时仅授予对 127.0.0.1:3000 的访问权限,我会在 Authentication#welcome Showing /Volumes/Develop/login_app/app 中收到类似 oMethodError 的错误消息/views/authentication/welcome.html.erb 其中第 6 行提出:
undefined method `user_session_path' for #<ActionDispatch::Routing::RoutesProxy:0x007ffb4d711a10>
Extracted source (around line #6):
我在根站点上有登录和登录..看起来像这样
<h1>Hello</h1>
<h2>Sign in</h2>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<% if devise_mapping.rememberable? -%>
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
<% end -%>
<div><%= f.submit "Sign in" %></div>
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
现在有人可以来将 127.0.0.1/signin 放在 url 中,然后它会显示 sign_in 表单,我会避免这种情况,因为它应该显示在根站点上......就像 sing_up 一样的场景......谢谢