我一直在尝试使用设计进行身份验证,然后使用omniauth,但我无法获得用户会话。
在我的应用程序控制器中,我有
类 ApplicationController < ActionController::Base
防止伪造
私人的
定义当前用户
@current_user ||= User.find(session[:user_id]) if session[:user_id]
结尾
helper_method :current_user
结尾
我从更新后的 railscast https://github.com/railscasts/241-simple-omniauth/blob/master/revised/blog-after/app/controllers/application_controller.rb
在我的应用程序中,我调用
<% if current_user %>
但这总是错误为undefined local variable or method 'current_user'
为什么是这样?这是我的应用程序控制器的问题,还是rails的会话错误?