Blog / How HTTP Requests work in Rails

How HTTP Requests work in Rails

Blair Rorani

February 23, 2021

Process overview

⚠️ This is how HTTP requests work without any interaction with the model.

[request] ➡️ routes.rb ➡️ [controller] + [action] ➡️ view ➡️ browser

  1. A browser sends an HTTP request
  2. The Rails server receives the request
  3. routes.rb tells Rails which [controller] + [action] to send the request to (e.g. about#index)
  4. The [controller] receives the request and runs code in the method that matches the [action] from routes.rb
  5. Rails generates a view (e.g. index.html.erb)
  6. Rails sends the view back to the browser
  7. The browser renders the view

Example HTTP request and response

⚠️ A model is included in later guides.

🔗 Link to REST tutorial via Thoughtbot

P.S. You might enjoy following me on Twitter.


Comments
Loading...

Want to stay up-to-date with Ruby on Rails?

Join 45,185+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.