MVC action in Ruby on Rails
Ruby on Rails is a framework that conforms to Model-View-Controller (MVC) pattern.
Here is a scenario of what happens in Ruby on Rails application, when a user visits the user index page at /users explained by Michael Hartl in Ruby on Rails Tutorial: Learn Rails by Example.
- The browser issues a request for the /users URL.
- Rails routes /users to the index action in the Users controller.
- The index action asks the User model to retrieve all users (User.all).
- The User model pulls all the users from the database.
- The User model returns the list of users to the controller.
- The controller captures the users in the @users variable, which is passed to the index view.
- The view uses Embedded Ruby to render the page as HTML.
- The controller passes the HTML back to the browser.