What is the Rails request-response lifecycle?

Answer

A Rails request goes through these steps: 1) Web server (Puma/Nginx) receives the HTTP request. 2) Rack middleware stack processes the request (logging, sessions, CSRF, etc.). 3) Router matches the URL and HTTP verb to a controller action. 4) Controller action runs — calls model methods, assigns instance variables. 5) View renders a template using instance variables from the controller. 6) Response is sent back through the middleware stack to the browser. The whole stack is built on Rack, a Ruby web server interface that standardizes how web servers and frameworks communicate.