[RUBY] [Note] MVC model simple summary

Introduction

I have compiled and left a memorandum of various knowledge that the author has caught.

What is MVC

An abbreviation for Model acronym "M", View acronym "V", and Controller acronym "C", a concept for organizing application settings. The image is a flow in which the content entered (clicked) by the user in the browser is processed by the Web application.

Ruby on Rails consists of an MVC model.

Model

This is the part that handles application-specific data. Process in response to a request from Controller (Sometimes you write the process directly in Model (Example: "Search for a specific character string and extract it", "Do not put a blank in this item of the database", etc. )). Performs data registration, acquisition, update, deletion, etc. on the database.

View

The part related to the PC screen. When displaying database information, receive the information from the Controller and actually assemble the HTML to be displayed on the browser.

Controller

This is the part that controls Model and View. In response to requests from users (eg, wanting to see a list of products (products registered in the database) from TOP, etc.), it controls how to link with Model and which View (screen) is displayed.

In Ruby on Rails

By dividing the structure of the program according to the role of MVC, it is possible to improve the maintainability of the program and limit the parts that affect when developing with multiple people.

When abstracted

View is open Controller promotes business Model is office work

When displaying View (product list) View: Since we received an inquiry, please give us a catalog for presentations to show to Controller customers! Controller: Understood! View! Model! Bring it from the cabinet! Model: controller, I understand. I'll get it now.

When a user is registered as a new member in View View: Controller I received a request from a customer! Controller: Thank you! View! Give it to Model! Model: controller, I understand. I'll keep a record.

And for each role, the work is routineized to improve efficiency.

I have an image like that.

Recommended Posts

[Note] MVC model simple summary
MVC model
A simple example of an MVC model
uri library simple summary
What is MVC model?
[Swift] Simple screen transition summary