2014-03-26 2 views
0

Rails 4 앱에서 Sorcery를 인증에 사용하고 있는데 current_users 메소드를 사용할 수 없습니다. 나는 다음과 같은 오류가 계속 :Sorcery - current_users not working

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 

답변

0

당신은 아마 활동 로깅 모듈을 사용할 필요는 없습니다.

그것을 포함하도록 초기화를 변경

:

Rails.application.config.sorcery.submodules = [:activity_logging, whatever_else] 
0

내가 그랬던 것처럼 당신이 다음 서브 모듈이 자동으로 추가됩니다의 wiki guide을 다음과 같은 경우. 문제는 두 가지 다음이다 : 당신은 당신은

current_users.map {|u| u.username}.join(", ")

current_users.map {|u| u.email}.join(", ")를 이메일로 사용자 이름 필드를 설정하는 것이 확인하거나 변경할 필요가 서버에게 당신의 레일

  • 를 다시 시작해야