The Rails Request Cycle

40 %
60 %
Information about The Rails Request Cycle

Published on October 2, 2007

Author: lachie

Source: slideshare.net

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

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

PART ZERO

ocol adap prot ter dispatcher controller view

principle info passed via arguments via objects return value ignored

protocol adapter dispatcher controller view

principle

PART ONE

The Dispatcher:

The Dispatcher: just a class™

dispatch(cgi, session_options, output) Dispatcher

fastcgi webrick mongrel cgi.rb Dispatcher

classic CGI

classic CGI supported

classic CGI supported Who cares?

Finesse arguments. Find Controller. Delegate to Controller. Handle errors. Tidy up.

Finesse arguments. request response cgi.rb cgi.rb

Find Controller. ROUTING populates request

Delegate to Controller. controller_class.process(request,response)

Handle errors. begin dispatcher controller view bo om ! rescue Exception => exception end

Handle errors. rescue Exception => exception controller_class.process_with_exception (request,response,exception) end end

Handle errors. rescue Exception => exception failsafe_response(output, '500 Internal Server Error', exception) do controller_class.process_with_exception (request,response,exception) end end

Tidy up. production # no-op

Tidy up. production # no-op otherwise framework tidy-up hooks Dependencies ActiveRecord

response headers body

PART TWO

Your controller:

Your controller: just an object™

process(request,response,method, *args) ActionController

Setup instance. Dispatch action. Render. Finesse response. Tidy up.

Setup instance. Set up the magic to make your actions sing!

Setup instance. Housekeeping

Setup instance. handy accessors from request: from response: response request params template cookies session headers

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

Dispatch action. -or- method missing (and, render if you haven't).

Dispatch action. -or- just render.

Render. VIEWY

Render. @assigns = instance_vars - protected_vars

Finesse response. text/html Tidy up. close session

Where are

Where are filters?

Where are filters? mixin!

Where are filters? mixin! helpers?

Where are filters? mixin! helpers? mixin!

principle Solid basics + Fancy stuff.

5 minute talk subject: How we choose your view for you.

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

THE END

Add a comment

Related pages

Examining The Internals Of The Rails Request/Response Cycle

Come with me on a journey through the internals of Rails, as we trace a request from the web server to the controller action method, and follow the ...
Read more

Request-Response Cycle III | Codecademy

Guide for navigating a Rails app with a form. When developing a Rails app, the request/response cycle is a useful guide to trace how a user's request flows ...
Read more

Request-Response Cycle II | Codecademy

When developing a Rails app, the request/response cycle is a useful guide to see how all the app's files and folders fit together. The request/response ...
Read more

ruby rails web request response lifecycle - Stack Overflow

i'm a novice in ruby on rails trying to understand the indepth flow of a typical request/ response life cycle in ruby on rails web application. i have ...
Read more

How Rails Works: The Rails Request Cycle — Medium

How Rails Works: The Rails Request Cycle. Ruby is a wonderful programming language. So much power, so much potential, so little syntax. I cannot imagine a ...
Read more

The Rails Request Cycle – Medium

The Rails Request Cycle. Let me tell you about something exciting!: THE RAILS CYCLE! First, Rails matches route on route. The Router is basically just a ...
Read more

Action Controller Overview — Ruby on Rails Guides

Action Controller Overview. In this guide you will learn how controllers work and how they fit into the request cycle in your application. After reading ...
Read more

Getting Started with Rails — Ruby on Rails Guides

Getting Started with Rails. This guide covers getting up and running with Ruby on Rails. After reading this guide, you will know: How to install Rails ...
Read more