class ApplicationController < ActionController::Base
around_filter do |controller, action|
controller.instance_eval do
returned = catch(:render){ action.call }
if returned == :render
default_render unless performed?
else
returned
end
end
end
protected
def render! *a, &b
render *a, &b unless(a.empty? and b.nil?)
throw :render, :render
end
def redirect_to! *a, &b
redirect_to *a, &b
ensure
render!
end
def redirect_to_url! *a, &b
redirect_to_url *a, &b
ensure
render!
end
def return_to! url = session[:return_to]
redirect_to_url! url
end
end
class ApplicationController < ActionController::Base
protected
def require_login
redirect_to! login_path unless current_user
end
end