request-response cycle of ruby on rails app

5
RequestResponse Ruby on Rails Nathalie Steinmetz http://github.com/natsteinmetz http://linkedin.com/in/nathaliesteinmetz

Upload: nathalie-steinmetz

Post on 05-Dec-2014

1.067 views

Category:

Technology


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

Page 1: Request-Response Cycle of Ruby on Rails App

Request-­‐ResponseRuby  on  Rails  

Nathalie  Steinmetz  http://github.com/natsteinmetz  

http://linkedin.com/in/nathaliesteinmetz    

Page 2: Request-Response Cycle of Ruby on Rails App

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  

Page 3: Request-Response Cycle of Ruby on Rails App

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  

Page 4: Request-Response Cycle of Ruby on Rails App

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)  

Page 5: Request-Response Cycle of Ruby on Rails App

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.)