【发布时间】:2016-02-25 22:29:48
【问题描述】:
我使用了 devise gem 并使用以 User 为名称的 devise 命令生成了视图。
为了在整个应用程序中显示登录/注销链接,我将其添加到我的 layouts/application.html.erb
<% if user_session.present? %>
<%= link_to "logout", destroy_user_session_path, :method => 'delete' %>
<% else %>
<%= link_to "Login", new_user_session_path, :method => 'get' %>
<% end %>
<%= yield %>
这是只有索引操作的主控制器:
class HomeController < ApplicationController
def index
end
end
根被定义为指向home#index。
当我启动应用程序时,它显示登录链接,点击该链接后,我收到以下错误:
Started GET "/users/sign_in" for ::1 at 2015-11-23 23:15:32 +0530
Processing by Devise::SessionsController#new as HTML
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
Redirected to http://localhost:3000/
Filter chain halted as :require_no_authentication rendered or redirected
Completed 302 Found in 10ms (ActiveRecord: 0.3ms)
Started GET "/" for ::1 at 2015-11-23 23:15:32 +0530
Processing by HomeController#index as HTML
Rendered home/index.html.erb within layouts/application (0.1ms)
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1
Completed 200 OK in 8ms (Views: 6.7ms | ActiveRecord: 0.4ms)
请建议我哪里出错了。我无法找出错误。
【问题讨论】:
标签: ruby-on-rails ruby devise