Posts

Showing posts with the label Request

๐Ÿš€ Ruby on Rails Action Controller — The Complete Deep Dive Guide (From Request to Response!)

Image
๐Ÿš€ Ruby on Rails Action Controller — The Complete Deep Dive Guide (From Request to Response!) When a user clicks a button on your Rails app… ๐Ÿ’ก What exactly happens behind the scenes? How does the request travel from the browser → server → router → controller → model → view → and back? Today, we’ll break down Ruby on Rails Action Controller in full depth — step by step, class by class, parameter by parameter. ๐ŸŒ 1️⃣ The Journey Begins: HTTP Request When a user hits: https://yourapp.com/posts/1 The browser sends an HTTP request like: GET /posts/1 HTTP/1.1 This request contains: ๐Ÿ›ฃ Path: /posts/1 ๐Ÿ” HTTP Verb: GET ๐Ÿ“ฆ Headers ๐Ÿงพ Cookies ๐Ÿงฎ Query Parameters ๐Ÿ” Session info Now Rails takes over. ๐Ÿ”ฅ 2️⃣ Rack — The Entry Point Rails sits on top of Rack (Ruby Webserver Interface). Flow: Web Server (Puma) ↓ Rack Middleware Stack ↓ Rails Application Rails app responds to: call (env) Where: env = Huge Hash containing request details. Example: env [ "REQUEST_METHOD" ] # =...