Last active
November 3, 2016 21:47
-
-
Save nativestranger/af3ff70d1cd03ea9376aed34c79a168e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# within app/admin/users.rb | |
member_action :impersonate, :method => :get do | |
user = User.find(params[:id]) | |
begin | |
flash[:notice] = "Successfully logged in as : #{user.email} #{view_context.link_to('Be careful!', root_path)}".html_safe | |
warden.set_user(resource,{:scope=>:user,:run_callbacks=>false}) | |
rescue | |
flash[:error] = "Unable to log you in. Poop." | |
end | |
redirect_to admin_users_path | |
end | |
action_item(:impersonate, only: :show) do | |
link_to('Impersonate', impersonate_admin_user_path(resource)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment