Request-Response Cycle of Ruby on Rails App

Post on 05-Dec-2014

1,068 views 2 download

description

This presentation describes the Request-Response cycle that a Ruby on Rails app goes through, narrowing in from a high level to a low level, and back.

transcript

Request-­‐ResponseRuby  on  Rails  

Nathalie  Steinmetz  http://github.com/natsteinmetz  

http://linkedin.com/in/nathaliesteinmetz    

User  Browser   DNS  Server  

(1)  DNS  Lookup  (http://codefellows.org)  

(2)  IP  Address  

Web  Server  (for  example  Apache)  

(3)  HTTP  Request              [URI]  (http://codefellows.org)              [method]  (GET)                          [request  header]  (user  agent,  etc.)  

Application  Server    (for  example  Phusion  Passenger)  

(4)  Recognized  Ruby                application  request  –                  forward  to  app  server  

HIGH  LEVEL  

Ruby  Version  Manager  

Gemfile  

Rails  Routes  

(5)  Go  to  RVM  

(6)  Check  Rails  version                  in  Gemfile  

(7)  Check  routes  using  HTTP                request  URI  and  method  

MI  D    LEVEL  

LOW    LEVEL  

Controller  

Model  

View  

(9)  Go  to  Model,                  get  data  from                database  

(8)  Go  to  appropriate  controller  (index)  

Controller  

(10)  Return  to                      controller    

(11)  Compile  response  body  (HTML)  

Application  Server    (for  example  Phusion  Passenger)  

HIGH  LEVEL   Web  Server  (for  example  Apache)   User  Browser  

(14)  Render  view  

(12)  Send  HTTP  Response  to  app  server                    [Status  code]  (200)                    [Response  header]  (cookie,  etc.)                    [Response  body]  (HTML,  CSS,  Javascript)  

(13)  Forward  HTTP  Response  

Repeat  for  linked  files  (CSS,  images,  etc.)