在使用带有 Rails 的 Devise 成功注册后,我遇到了登录问题。
我得到这个错误。
没有路线匹配 [POST] "/sessions/user"
我不确定为什么。我有一个名为“会话”的模型,这可能是为什么?
这是视图-
<ul class="nav pull-right">
<% if user_signed_in? %>
<li><%= link_to current_user.full_name, edit_user_registration_path %></li>
<li><%= link_to "log out", destroy_user_session_path, method: :delete %></li>
<% else %>
<li><%= link_to "Register", new_user_registration_path %></li>
<li><%= link_to "Log in", new_user_session_path %></li>
<% end %>
</ul>
这是'rake routes'的输出
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
sessions GET /sessions(.:format) sessions#index
POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
edit_session GET /sessions/:id/edit(.:format) sessions#edit
session GET /sessions/:id(.:format) sessions#show
PUT /sessions/:id(.:format) sessions#update
DELETE /sessions/:id(.:format) sessions#destroy
root / sessions#index
我已经四处搜索,但没有找到任何重复项,如果您在这里发现了什么,请告诉我。感谢您对此的帮助。
登录页面——
<div class="row">
<div class="span4">
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: "well"} ) do |f| %>
<fieldset>
<legend>Sign in</legend>
<%= f.input :email %>
<%= f.input :password %>
<% if devise_mapping.rememberable? -%>
<div><%= f.input :remember_me, as: :boolean %> </div>
<% end -%>
<div><%= f.button :submit, "Sign in" %></div>
</fieldset>
<% end %>
<%= render "devise/shared/links" %>
</div>
<div class="span8">
<h2>Signing in is easy and secure!</h2>
</div>
</div>