2013-10-22 54 views
2

我正在使用switch_user寶石這question幾乎與我有確切的問題。我曾嘗試過與問題中相同的內容,如readme所述。這是我嘗試過的代碼。無法切換回用戶使用切換用戶寶石軌道

config.controller_guard = { |current_user, request, original_user| 
    current_user && current_user.has_role? :admin || original_user} 

    # view_guard is a block, 
    # if it returns true, the switch user select box will be shown, 
    # else the select box will not be shown 
    # if you switch from admin to "user", the current_user param is "user" 
config.view_guard = { |current_user, request, original_user| 
    current_user && current_user.has_role? :admin || original_user} 
    # redirect_path is a block, it returns which page will be redirected 
    # after switching a user. 

# if lambda{|current_user| current_user.admin?} 
# config.redirect_path = lambda{|request,params| "/admin_dashboard"} 
# elsif lambda{|current_user| current_user.performer?} 
# config.redirected_path = lambda{|request,params| "/"} 
# elsif lambda{|current_user| current_user.white_label?} 
# config.redirected_path = lambda{|request,params| "/white_label_dashboard"} 
# else 
# config.redirected_path = lambda{|request,params| "/customer_dashboard"} 
# end 
    # helper_with_guest is a boolean value, if it set to false 
    # the guest item in the helper won't be shown 
    config.helper_with_guest = false 

    # false = login from one scope to another and you are logged in only in both scopes 
    # true = you are logged only into one scope at a time 
    config.login_exclusive = true 

    # switch_back allows you to switch back to a previously selected user. See 
    # README for more details. 
config.switch_back = true 

我仍然無法切換回來。我怎麼才能找到原始用戶是否已設置?

回答

0

如果有人仍然在掙扎switch_user寶石,我強烈建議Pretender by Ankane。我在10分鐘內安裝了它。