Class: Morphing::MorphingController

Inherits:
ApplicationController show all
Defined in:
app/controllers/morphing/morphing_controller.rb

Instance Method Summary collapse

Instance Method Details

#morphObject



3
4
5
6
7
8
9
10
# File 'app/controllers/morphing/morphing_controller.rb', line 3

def morph
  morph_to = User.find(params[:id])
  session[:morphed_from]  = current_user.id
  (:user, morph_to)

  flash[:success] = "Morphed into #{morph_to.name}"
  redirect_back_or_to_root
end

#unmorphObject



12
13
14
15
16
17
18
19
# File 'app/controllers/morphing/morphing_controller.rb', line 12

def unmorph
  if morph_from = User.find_by_id(session[:morphed_from])
    session.delete :morphed_from
     :user, morph_from
  end

  redirect_back_or_to_root
end