SlideShare a Scribd company logo
by Raphael Monteiro - 04/2015
Rails in the bowels
Things that nobody(or almost nobody) talk
about.
Keep the secret or DIE!!(just kidding S2)
● Rails on Rack (What the RACK is going on?!)
● ‘Action Dispatch: Where it all begins’
‘Rack aims to provide a minimal API for
connecting web server and web frameworks’
Rack provides a minimal, modular and adaptable interface for
developing web applications in Ruby. By wrapping HTTP requests
and responses in the simplest way possible, it unifies and
distills the API for web servers, web frameworks, and software
in between (the so-called middleware) into a single method call.
● Example: rails server
RACK
(process
and build)
Web Server
and
App Server
(Webrick)
Browser
(Client side)
Web
Framework
● The most simple Rack application
● Rails 2.3, request handling was moved to
Rack and the concept of middleware was
introduced.
● Classes that satisfy Rack's call interface can
be chained together as filters. (Rack
Middleware)
● Much of Action Controller is implemented
as Rack middleware modules.
$ rake middleware
Rails in the bowels
Rails in the bowels
● You can create your own middleware
● config/application.rb ou environment/*.rb
● config.middleware.use(new_middleware, args)
● config.middleware.insert_before(existing_middl
eware, new_middleware, args)
● Don't forget to initizalize and call app.call(env)
● Rack is a framework to roll your own ruby framework.
● Rack provides an interface between different web servers and your framework/application.
Making it very simple for your framework/application to be compatible with any webserver
that supports Rack – Phusion Passenger, Litespeed, Mongrel, Thin, Ebb, Webrick to name a
few.
● Rack cuts your chase. You get request, response, cookies, params & sessions for free.
● Makes it possible to use multiple frameworks for the same application, provided there is no
class collision. Rails and sinatra integration is a good example of this.
● Middlewares ! Think of middlewares as Rails’s before_filter/after_filter that are reusable across
different rack supported frameworks/applications. For example, you can use the same Anti-
spamming rack middleware for your Rails app, Sinatra app and your custom Rack application
too!
● The entry point to a request is an instance of
ActionDispatch::Routing::RouteSet
● Example:
route: get 'foo', to: 'foo#index'
instance: FooController.action(:index).call
Rails in the bowels
Rails in the bowels
Rails in the bowels
endpoint is our application's routes, an instance of ActionDispatch::Routing::RouteSet
● Operational::Application.routes
and then invoke the #call method...
@router is an instance of Journey::Router
● Journey is the core routing module in
ActionDispatch.
● It is constructed by the code you define in
config/routes.rb
Rails in the bowels
● When constructing the routing table, the
ActionDispatch::Routing::Mapper class calls
add_route, which will construct a
Journey::Route instance associated with a
controller endpoint (the Rack app) and add it
to the routing table.
Rails in the bowels
● @set is the RouteSet
● app referenced here is an instance of
ActionDispatch::Routing::Dispatcher
Rails in the bowels
Finally…
FooController.action(:index).call
● Rack Creator:
http://chneukirchen.org/blog/archive/2007/02/introducing-rack.html
● Inside Rack and ActionDispatcher: http://pothibo.com/2013/11/ruby-on-
rails-inside-actiondispatch-and-rack/
● Understaing Rails from request to response in 3 parts(part I):
http://andrewberls.com/blog/post/rails-from-request-to-response-part-
1--introduction
● How to create a Ruby web server:
https://github.com/macournoyer/tube
● The Rails 4 Way, O. Fernandez, K. Faustino, June 2014

More Related Content

PPTX
Laravel Events And Queue
PPTX
signalr
PPTX
SignalR with ASP.NET MVC 6
PPTX
SignalR with asp.net
PPTX
SignalR. Code, not toothpaste - TechDays Belgium 2012
PDF
From monolith web app to micro-frontends
PPTX
DotNet Conf Madrid 2019 - ASP.NET Core 3
PPTX
Microsoft signal r
Laravel Events And Queue
signalr
SignalR with ASP.NET MVC 6
SignalR with asp.net
SignalR. Code, not toothpaste - TechDays Belgium 2012
From monolith web app to micro-frontends
DotNet Conf Madrid 2019 - ASP.NET Core 3
Microsoft signal r

What's hot (20)

PPTX
Real time web with SignalR
PPT
DOCX
Rails Concept
PDF
SignalR
PPTX
SignalR for ASP.NET Developers
PPTX
Introduction to SignalR
PPT
Introduction To Ruby On Rails
PPT
Intro to signalR
PDF
Introduction to SignalR
PPSX
SignalR With ASP.Net part1
PDF
Serverless architecture
PPTX
Angular Owin Katana TypeScript
PPTX
Real-time ASP.NET with SignalR
PPTX
Building Realtime Web Applications With ASP.NET SignalR
PPT
Intro to SPA using JavaScript & ASP.NET
PPTX
SignalR Overview
PPTX
Scale your signalR realtime web application
PDF
Wire once, rewire twice! (Haskell exchange-2018)
PPTX
Mule soft meetup__official__feb-27_2021
PPTX
Angular
Real time web with SignalR
Rails Concept
SignalR
SignalR for ASP.NET Developers
Introduction to SignalR
Introduction To Ruby On Rails
Intro to signalR
Introduction to SignalR
SignalR With ASP.Net part1
Serverless architecture
Angular Owin Katana TypeScript
Real-time ASP.NET with SignalR
Building Realtime Web Applications With ASP.NET SignalR
Intro to SPA using JavaScript & ASP.NET
SignalR Overview
Scale your signalR realtime web application
Wire once, rewire twice! (Haskell exchange-2018)
Mule soft meetup__official__feb-27_2021
Angular
Ad

Viewers also liked (15)

PDF
Jurassic JavaScript Park - Rodando Offline até na ilha Nublar!
PDF
A arte de ser Mensch
PDF
How To Get Organized
PDF
Debugging with pry
PDF
Positive reinforcement and statistics
PDF
O que o seu texto diz sobre você
PDF
O paradoxo da escolha
PDF
Modern sql
PDF
Sublime
PDF
Text mining Pre-processing
PDF
OOCSS and SMACSS
PDF
An introduction to MySQL
PPTX
Como melhorar sua comunicação com sua equipe, sua mãe e seu chefe
PPTX
Pig - Analyzing data sets
PDF
Melanoma: how to detect skin cancer
Jurassic JavaScript Park - Rodando Offline até na ilha Nublar!
A arte de ser Mensch
How To Get Organized
Debugging with pry
Positive reinforcement and statistics
O que o seu texto diz sobre você
O paradoxo da escolha
Modern sql
Sublime
Text mining Pre-processing
OOCSS and SMACSS
An introduction to MySQL
Como melhorar sua comunicação com sua equipe, sua mãe e seu chefe
Pig - Analyzing data sets
Melanoma: how to detect skin cancer
Ad

Similar to Rails in the bowels (20)

PDF
Rails request & middlewares
PPT
Ruby On Rails Siddhesh
PPTX
Rails Request & Middlewares
PDF
Intro to Rack
PPT
Ruby On Rails Seminar Basis Softexpo Feb2010
PDF
.NET Architects Day - DNAD 2011
PDF
09 - Fábio Akita - Além do rails
PDF
Ruby On Rails
PDF
Rack
PDF
Aspose pdf
PPT
Viridians on Rails
PPTX
Onion Architecture with S#arp
PPTX
Sinatra
PDF
Guide to Using React Router V6 in React Apps.pdf
PPTX
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
PPT
java web services - soap and rest services
PDF
Node.js Course 2 of 2 - Advanced techniques
PDF
Ruby on Rails Scaffold_ Create Your App In Minutes
PPTX
Ruby on Rails Penetration Testing
PDF
Ruby On Rails Basics
Rails request & middlewares
Ruby On Rails Siddhesh
Rails Request & Middlewares
Intro to Rack
Ruby On Rails Seminar Basis Softexpo Feb2010
.NET Architects Day - DNAD 2011
09 - Fábio Akita - Além do rails
Ruby On Rails
Rack
Aspose pdf
Viridians on Rails
Onion Architecture with S#arp
Sinatra
Guide to Using React Router V6 in React Apps.pdf
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
java web services - soap and rest services
Node.js Course 2 of 2 - Advanced techniques
Ruby on Rails Scaffold_ Create Your App In Minutes
Ruby on Rails Penetration Testing
Ruby On Rails Basics

More from Creditas (12)

PPTX
Hanami & Domain-Driven Design
PDF
Application layer
PDF
Hanami with a modern touch
PDF
Rails Girls - RubyConfBR 2015
PPTX
GTD - Getting Things Done
PDF
Neo4 j
PDF
Learning how to learn
PDF
Solid - OOD Principles
PPTX
Sistemas de recomendação em ruby
PDF
Do MONOLÍTICO à arquitetura distribuída
PDF
Minitest
PDF
Deploy Heroku
Hanami & Domain-Driven Design
Application layer
Hanami with a modern touch
Rails Girls - RubyConfBR 2015
GTD - Getting Things Done
Neo4 j
Learning how to learn
Solid - OOD Principles
Sistemas de recomendação em ruby
Do MONOLÍTICO à arquitetura distribuída
Minitest
Deploy Heroku

Recently uploaded (20)

PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Getting Started with Data Integration: FME Form 101
PDF
Machine learning based COVID-19 study performance prediction
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
1. Introduction to Computer Programming.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
SOPHOS-XG Firewall Administrator PPT.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Unlocking AI with Model Context Protocol (MCP)
Getting Started with Data Integration: FME Form 101
Machine learning based COVID-19 study performance prediction
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
MYSQL Presentation for SQL database connectivity
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Group 1 Presentation -Planning and Decision Making .pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
1. Introduction to Computer Programming.pptx
Network Security Unit 5.pdf for BCA BBA.
Reach Out and Touch Someone: Haptics and Empathic Computing
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Dropbox Q2 2025 Financial Results & Investor Presentation

Rails in the bowels

  • 3. Things that nobody(or almost nobody) talk about. Keep the secret or DIE!!(just kidding S2)
  • 4. ● Rails on Rack (What the RACK is going on?!) ● ‘Action Dispatch: Where it all begins’
  • 5. ‘Rack aims to provide a minimal API for connecting web server and web frameworks’ Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between (the so-called middleware) into a single method call.
  • 6. ● Example: rails server RACK (process and build) Web Server and App Server (Webrick) Browser (Client side) Web Framework
  • 7. ● The most simple Rack application
  • 8. ● Rails 2.3, request handling was moved to Rack and the concept of middleware was introduced. ● Classes that satisfy Rack's call interface can be chained together as filters. (Rack Middleware)
  • 9. ● Much of Action Controller is implemented as Rack middleware modules. $ rake middleware
  • 12. ● You can create your own middleware ● config/application.rb ou environment/*.rb ● config.middleware.use(new_middleware, args) ● config.middleware.insert_before(existing_middl eware, new_middleware, args) ● Don't forget to initizalize and call app.call(env)
  • 13. ● Rack is a framework to roll your own ruby framework. ● Rack provides an interface between different web servers and your framework/application. Making it very simple for your framework/application to be compatible with any webserver that supports Rack – Phusion Passenger, Litespeed, Mongrel, Thin, Ebb, Webrick to name a few. ● Rack cuts your chase. You get request, response, cookies, params & sessions for free. ● Makes it possible to use multiple frameworks for the same application, provided there is no class collision. Rails and sinatra integration is a good example of this. ● Middlewares ! Think of middlewares as Rails’s before_filter/after_filter that are reusable across different rack supported frameworks/applications. For example, you can use the same Anti- spamming rack middleware for your Rails app, Sinatra app and your custom Rack application too!
  • 14. ● The entry point to a request is an instance of ActionDispatch::Routing::RouteSet ● Example: route: get 'foo', to: 'foo#index' instance: FooController.action(:index).call
  • 18. endpoint is our application's routes, an instance of ActionDispatch::Routing::RouteSet
  • 19. ● Operational::Application.routes and then invoke the #call method...
  • 20. @router is an instance of Journey::Router
  • 21. ● Journey is the core routing module in ActionDispatch. ● It is constructed by the code you define in config/routes.rb
  • 23. ● When constructing the routing table, the ActionDispatch::Routing::Mapper class calls add_route, which will construct a Journey::Route instance associated with a controller endpoint (the Rack app) and add it to the routing table.
  • 25. ● @set is the RouteSet ● app referenced here is an instance of ActionDispatch::Routing::Dispatcher
  • 28. ● Rack Creator: http://chneukirchen.org/blog/archive/2007/02/introducing-rack.html ● Inside Rack and ActionDispatcher: http://pothibo.com/2013/11/ruby-on- rails-inside-actiondispatch-and-rack/ ● Understaing Rails from request to response in 3 parts(part I): http://andrewberls.com/blog/post/rails-from-request-to-response-part- 1--introduction ● How to create a Ruby web server: https://github.com/macournoyer/tube ● The Rails 4 Way, O. Fernandez, K. Faustino, June 2014

Editor's Notes

  • #13: That app parameter during the initialization is actually the next middleware in the chain.