【发布时间】:2015-03-14 21:52:11
【问题描述】:
(找不到具有 'id'=logout 的用户)的可能解决方案是什么?。我很感激任何意见。我能找到的只是对错误的引用。提前致谢。
ActiveRecord::RecordNotFound (Couldn't find User with 'id'=logout):
app/controllers/users_controller.rb:16:in `show'
users_controller.rb
line 15: def show
line 16: @user = User.find(params[:id])
line 17: end
routes.rb
delete 'logout' => 'sessions#destroy'
views/layout/application.html.erb
<% if logged_in? %>
<li><%= link_to current_user.name, current_user %></li>
<li><%= link_to "Log out", logout_path, method: :delete %></li>
<% else %>
<li><%= link_to "Log in", login_path %></li>
<% end %>
【问题讨论】:
-
你能发布更多或你的代码。喜欢你的链接到
logoutin view -
我添加了相关的注销视图。感谢您的帮助。
-
能否发布您的整个 routes.rb 和
rake routes的输出? -
尝试用这个
delete ':id', to: 'sessions#destroy', as: :logout替换路由文件中的那一行
标签: ruby-on-rails postgresql webrick