Module: UsableClass
- Defined in:
- lib/ubiquitous_user.rb
Class Method Summary collapse
Class Method Details
.authorize(message = "Please log in.", key = :warning) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ubiquitous_user.rb', line 73 def ( = "Please log in.", key = :warning) Proc.new do |controller| unless controller.user_logged_in? # flash, redirect_to and new_session_url are protected. Thank god this is Ruby, not Java. controller.send(:flash)[key] = begin controller.send(:redirect_to, :back) rescue ActionController::RedirectBackError controller.send(:redirect_to, controller.send(:new_session_url)) end end end end |