CRUD features and MVC in Rails


This is an output article for beginners. I would appreciate it if you could point out.

What is the CRUD function?

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)

What is MVC?

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.

MVC Why did you do it?

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.


Mechanism for operating the database

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.


Interface design to show to the user (page appearance)

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.


Mechanism for linking user requests with Model and View

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.


Mechanism for connecting URL and application

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.

Recommended Posts

CRUD features and MVC in Rails
Enable jQuery and Bootstrap in Rails 6 (Rails 6)
Remove "assets" and "turbolinks" in "Rails6".
Rails and FormData
MVC in Eclipse.
Group_by in Rails
(Basic authentication) environment variables in rails and Docker
Ruby on Rails ~ Basics of MVC and Router ~
[Rails] Ranking and pagination in order of likes
Summary of frequently used commands in Rails and Docker
Rails valid? And invalid?
Model association in Rails
Rails CRUD function implementation ② (edited and detailed this time)
Disable turbolinks in Rails
CSRF measures in Rails
^, $ in Rails regular expression
Understand migration in rails
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapters 4 and 5
Get location information in Rails and sort in ascending order
Split routes.rb in Rails6
Implement markdown in Rails
Differences between namespace, module, scope and as in Rails routing
Launch Nuxt.js + Rails API on Docker and try CRUD operation
[Rails] Introducing Travis CI and getting stuck in db: create
Implementation policy to dynamically save and display Timezone in Rails
Implement login function in Rails simply by name and password (2)
[Rails] How to define macros in Rspec and standardize processing
Implement login function simply with name and password in Rails (3)
Implement user registration function and corporate registration function separately in Rails devise
[Rails] Find_each loops endlessly and eats up memory in production
Get UserAgent in [Rails] controller
Implement application function in Rails
Java version 8 and later features
Declarative transaction in Rails #ginzarb
Implement follow function in Rails
[Rails] N + 1 problems and countermeasures
Rails Posts and User Linkage
[Rails] require method and permit method
Rails "render method" and "redirect method"
Micronaut CLI Profiles and Features
Rails Tutorial Records and Memorandum # 0
Japaneseize using i18n with Rails
rails path and url methods
Mock and stub in RSpec
Implement LTI authentication in Rails
Rails is difficult and painful!
Error in rails db: migrate
Introducing Bootstrap and Font-Awesome (Rails)
Rails is difficult and painful! Ⅱ
Gem often used in Rails
Display Flash messages in Rails
View monthly calendar in Rails
Implement import process in Rails
[Rails] strftime this and that
Use multiple checkboxes in Rails6!
Rails web server and application server
Rewrite Routes in Rails Engine
Remove nil and blank string array in rails Array and display them concatenated
Implemented hashtag search like Instagram and Twitter in Rails (no gem)
[Webpacker] Summary of how to install Bootstrap and jQuery in Rails 6.0
(Ruby on Rails6) Creating a database and displaying it in a view