The Rails Request Cycle

7,885 views

Published on

A journey through the Rails request cycle. It might be a bit hard to follow w/o the talk to go along with it.

From January 2007

Published in: Technology

The Rails Request Cycle

  1. 1. a myftical journey through the Request Cycle of RUBY ON RAILS. AN ORATION IN TWO PARTS L.C. BY
  2. 2. PART ZERO
  3. 3. ocol adap prot ter dispatcher controller view
  4. 4. principle info passed via arguments via objects return value ignored
  5. 5. protocol adapter dispatcher controller view
  6. 6. principle
  7. 7. PART ONE
  8. 8. The Dispatcher:
  9. 9. The Dispatcher: just a class™
  10. 10. dispatch(cgi, session_options, output) Dispatcher
  11. 11. fastcgi webrick mongrel cgi.rb Dispatcher
  12. 12. classic CGI
  13. 13. classic CGI supported
  14. 14. classic CGI supported Who cares?
  15. 15. Finesse arguments. Find Controller. Delegate to Controller. Handle errors. Tidy up.
  16. 16. Finesse arguments. request response cgi.rb cgi.rb
  17. 17. Find Controller. ROUTING populates request
  18. 18. Delegate to Controller. controller_class.process(request,response)
  19. 19. Handle errors. begin dispatcher controller view bo om ! rescue Exception => exception end
  20. 20. Handle errors. rescue Exception => exception controller_class.process_with_exception (request,response,exception) end end
  21. 21. Handle errors. rescue Exception => exception failsafe_response(output, '500 Internal Server Error', exception) do controller_class.process_with_exception (request,response,exception) end end
  22. 22. Tidy up. production # no-op
  23. 23. Tidy up. production # no-op otherwise framework tidy-up hooks Dependencies ActiveRecord
  24. 24. response headers body
  25. 25. PART TWO
  26. 26. Your controller:
  27. 27. Your controller: just an object™
  28. 28. process(request,response,method, *args) ActionController
  29. 29. Setup instance. Dispatch action. Render. Finesse response. Tidy up.
  30. 30. Setup instance. Set up the magic to make your actions sing!
  31. 31. Setup instance. Housekeeping
  32. 32. Setup instance. handy accessors from request: from response: response request params template cookies session headers
  33. 33. Dispatch action. instance method (and, render if you haven't).
  34. 34. Dispatch action. -or- method missing (and, render if you haven't).
  35. 35. Dispatch action. -or- just render.
  36. 36. Render. VIEWY
  37. 37. Render. @assigns = instance_vars - protected_vars
  38. 38. Finesse response. text/html Tidy up. close session
  39. 39. Where are
  40. 40. Where are filters?
  41. 41. Where are filters? mixin!
  42. 42. Where are filters? mixin! helpers?
  43. 43. Where are filters? mixin! helpers? mixin!
  44. 44. principle Solid basics + Fancy stuff.
  45. 45. 5 minute talk subject: How we choose your view for you.
  46. 46. json nothing xml ml ht How we choose ac ti on your view rjs for you. et la mp la yo te ut ile f text
  47. 47. THE END

×