This is an output article for beginners. I would appreciate it if you could point out.
An acronym for "Create," "Read," "Update," and "Delete," which are the four main functions required for the system.
Minimum functionality required when manipulating data
CRUD is a basic idea for creating web applications.
・ Create function ・ Read function (Read) ・ Update function (Update) -Delete function (Delete)
One of the design patterns for implementing application software with UI (user interface). Briefly, the page (URL) specified by oneself is processed in the order of routing → controller (C) → model (M) → view (V) before being displayed on the browser. The model is processed only when it is needed, so skip it when it is not needed.
Since the properties of the screen (UI) part and the data processing part are different while processing various applications, it will be complicated if you write the code together, so
View, which is in charge of appearance, A framework called MVC was created to make it easier to manage by dividing the roles of Model
, which processes application-specific data, View and Controller
that controls Model into three parts.
Executes after receiving instructions from the Controller to add, change, or delete data. A Model is prepared for each table in the database. Database tables are created by model classes and instances created from model classes.
app / views (located in the view folder of the application's main folder) There are usually multiple views, each in the form of HTML. Ruby code is embedded there, and the data received from Model by Controller is reflected in the corresponding HTML according to the requested action, and HTML is generated.
app / controllers (located in the controller folder of the application's main folder) Receive the request from the user, receive the necessary information from Model, and reflect the HTML generated by View on the screen. A role like a command tower that gives instructions to the Model and View. Like View, multiple actions are prepared, and multiple actions are prepared in one Controller.
The method in the controller is called an "action". A method for executing specific processing in response to a request from a user.
config / routes.rb (located in the roots file of the config folder) The role of connecting (= allocating processing) the URL accessed by the user via the browser and the action of the controller.