我在我的Rails 4應用程序中使用Sorcery進行身份驗證,並且無法使current_users方法正常工作。我不斷收到以下錯誤:魔法 - current_users無法正常工作
undefined local variable or method `current_users' for #<UsersController:0x007fc7b5a75588>
查看:
Currently active users: <%= current_users_list %>
Application_controller.rb:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_users_list
private
def not_authenticated
redirect_to login_url, :alert => "First log in to view this page."
end
def current_users_list
current_users.map {|u| u.email}.join(", ")
end
end