Request Response Cycle in Rails
Link ::
https://www.nopio.com/blog/ruby-rails-popular-job-interview-questions/
7. Explain request/response cycle.
Here is the request/response cycle:
Let’s explain request/response flow in Rails:
- The user opens their browser and enters a URL.
- The browser sends a GET request to the URL. The request hits the Rails Router (config/routes.rb).
- The router receives the request information from the web server and based on that, decides which controller action should be called. If a request matches to any path in the routes file, the corresponding controller and action will be called.
- The controller receives the parameters from the router and passes them into appropriate model methods.
- The model queries a database to fetch data.
- The Database returns stored data to the model.
- The model manages the data and returns it to the controller.
- The controller feeds the received data to the view.
- The view renders the page as HTML, prepares a response and forwards it to the controller.
- The controller forwards the ready response to the browser.
- The browser displays a response to the user
Comments
Post a Comment