Skip to content

Instantly share code, notes, and snippets.

@mallipeddi
Created August 6, 2010 07:52
Show Gist options
  • Select an option

  • Save mallipeddi/511010 to your computer and use it in GitHub Desktop.

Select an option

Save mallipeddi/511010 to your computer and use it in GitHub Desktop.
lib/action_controller/dispatcher.rb
dispatch method
calls handle_request
calls Routing::Routes#recognize(request) to figure out the correct 'controller'
once the controller has been identified, calls controller.process
if an exception gets thrown, do failsafe_rescue(exception)
failsafe_rescue
calls ApplicationController or ActionController::Base's process_with_exception (for Base, it's defined in rescue.rb)
lib/action_controller/rescue.rb
rescues from exceptions (monkey-patches perform_action of ActionController::Base)
rescue_responses
a hash which maps exceptions => status codes; status_codes are either numbers or symbols
process_with_exception
call controller's process with :rescue_action as the callback method
rescue_action
rescue_action_with_handler || rescue_action_without_handler
rescue_action_without_handler
rescue_action_locally || rescue_action_in_public
lib/action_controller/rescuable.rb
mixed into ActionController::Base in rescue.rb
rescue_action_with_handler
handle certain exceptions using the callbacks which the user might have assigned via :rescue_from in his/her controllers.
lib/action_controller/benchmarking.rb
monkey-patches perform_action also. this is what prints out all the statistics to the console (when using Mongrel via ./script/server)
lib/action_controller/base.rb
hold the :request, :response, :session, :headers, :action_name attributes
process
calls new.process(request, response, method = :perform_action, *arguments)
perform_action
invoke action
if action not known, raise UnkownAction exception
lib/action_controller/status_codes.rb (mixed into ActionController:Base)
STATUS_CODES
hash mapping numeric status-codes => string status text (eg: "200" => "OK")
interpret_status(status)
return the header['Status'] given the status code
arg `status` can be either :symbol or number
if :symbol, see if it matches any status text from STATUS_CODES text, and then pick that status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment