the rails request cycle

48
a myftical journey through the RUBY ON RAILS. Request Cycle of AN ORATION IN TWO PARTS BY L.C.

Upload: lachie

Post on 05-Dec-2014

10.793 views

Category:

Technology


2 download

DESCRIPTION

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

TRANSCRIPT

a myftical journeythrough the

RUBY ON RAILS.

Request Cycleof

AN

ORATIONIN

TWO PARTS

BY L.C.

PART

ZERO

view

dispatcher

controller

protocol adapter

principle

info passed via arguments

return value ignoredvia objects

view

controller

dispatcher

protocoladapter

principle

PART

ONE

The Dispatcher:

The Dispatcher:

just a class™

Dispatcher

dispatch(cgi, session_options, output)

Dispatcher

cgi.rb

fastcgi webrick mongrel

classicCGI

classicCGI

supported

classicCGI

Who cares?

supported

Finesse arguments.

Find Controller.

Delegate to Controller.

Handle errors.

Tidy up.

Finesse arguments.

request

cgi.rb

response

cgi.rb

Find Controller.

ROUTINGpopulatesrequest

Delegate to Controller.

controller_class.process(request,response)

Handle errors.

rescue Exception => exception end

begin

view

dispatcher

controller

boom!

Handle errors.

controller_class.process_with_exception(request,response,exception)

rescue Exception => exception

end

end

Handle errors.

controller_class.process_with_exception(request,response,exception)

rescue Exception => exception

failsafe_response(output, '500 Internal Server Error', exception) do

end

end

Tidy up.

production# no-op

Tidy up.

Dependencies

production# no-op

otherwiseframework tidy-up hooks

ActiveRecord

response

headers

body

PART

TWO

Your controller:

Your controller:

just an object™

ActionController

process(request,response,method, *args)

Setup instance.

Dispatch action.

Render.

Finesse response.

Tidy up.

Setup instance.

Set up the magic to make youractions sing!

Setup instance.

Housekeeping

Setup instance.

handy accessors

from request:

requestparamscookies

from response:responsetemplatesessionheaders

Dispatch action.

instance method(and, render if you haven't).

Dispatch action.

method missing(and, render if you haven't).

-or-

Dispatch action.

just render.

-or-

Render.

VIEWY

Render.

@assigns = instance_vars - protected_vars

Finesse response.

text/html

Tidy up.

close session

Where are

filters?Where are

filters?mixin!

Where are

filters?mixin!

Where are

helpers?

filters?mixin!

Where are

helpers?mixin!

Solid basics

Fancy stuff.+

principle

5 minute talk subject:

How we chooseyour viewfor you.

html

How we chooseyour viewfor you.

rjs

json xml

file

action

template

text

layout

nothing

THE

END