Ruby on Rails Developer Question:
Please explain request/response cycle?
Answer:
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.
☛ 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.
Previous Question | Next Question |
Explain me what Are The Components Defined In The Model From Mvc Architecture? | Explain what’s different between ActiveRecord::Relation’s count, length and size methods? |