a myftical journeythrough the
RUBY ON RAILS.
Request Cycleof
AN
ORATIONIN
TWO PARTS
BY L.C.
view
dispatcher
controller
protocol adapter
principle
info passed via arguments
return value ignoredvia objects
view
controller
dispatcher
protocoladapter
The Dispatcher:
just a class™
Dispatcher
dispatch(cgi, session_options, output)
Dispatcher
cgi.rb
fastcgi webrick mongrel
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
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.
@assigns = instance_vars - protected_vars
Finesse response.
text/html
Tidy up.
close session
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