How to Ruby on Rails- MVC Framework
Model-view-controller (MVC Framework) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, Model, View, and controller. Each of these components is built to handle specific development aspects of an application.
In Rails, the roles of the model, view and controller are well-defined by the framework, This tutorial explains all of it.
The browser makes a request to view a website,
The web server receives the request. It uses routes to find out which controller to use: the default route pattern is “/controller/action/id” as defined in config/routes.rb.
The model directly manages the data, logic, and rules of the application. Models are Ruby classes. They talk to the database, store and validate data, perform the business logic and otherwise do the heavy lifting. It maintains the relationship between the objects and the database and handles validation, association, transactions, and more.
The controller accepts input and converts it to commands for the model or view. Receive events from the outside world (usually through views). It interacts with the model. Action controller will display the appropriate view to the user.
When you have code that you use frequently in your views or that is too big to put inside of a view, you can define a method for it inside of a helper. All methods defined in the helpers are automatically usable in the views.