[RAILS] Relationship between database and model (basic)

About files related to the database

Purpose: I wrote this article because I thought that I had to understand the difference between the roles of model files and migration files in order to resolve errors.

Currently: We are in the final stage of portfolio creation, but there are still many things we do not understand, and we realize that we do not have enough basic understanding, and we are understanding from the mechanism while solidifying the basics.

Role of model file

This file shows the access authority to the database.
The model and association described indicate the access authority to the database through the model.

Why can't I retrieve this data? To understand, look at the model file that describes the access rights to the database. And it is the first step towards understanding.

Role of migration file

A file that describes the information required to store the contents of the data.
When passing data, specify the table name (class) and column name described in the file.

Why specify the table name (class)?

Summary

Understand both together

You will be able to understand the basics of how data is received from the database.

Unrelated models and models

Incidentally

Understanding the MVC phase

Advantages (impressions) of publishing the output

Do you really understand yourself? By writing while thinking many times, I was able to establish my knowledge.
Also, I don't know if it was a useful article for someone, but by publishing it on my blog, I was able to deeply understand and train my ability to communicate.
Thank you to everyone who read it.
If you have any mistakes, please do not hesitate to comment.

Recommended Posts

Relationship between database and model (basic)
Relationship between Controller and View
Relationship between package and class
Relationship between ActiveRecord with_lock and cache
[Java] Relationship between H2DB and JDBC
Relationship between kotlin and java access modifiers
[Note] Cooperation between Java and DB (basic)
Basic CRUD comparison between Mybatis and Hibernate
Relationship between Eclipse m2e plugin and Maven
Relationship between UI test and recording, implementation method
Model and table creation
About the relationship between HTTP methods, actions and CRUD
Verification of the relationship between Docker images and containers
Switch between JDK 7 and JDK 8
Difference between vh and%
Difference between i ++ and ++ i
Basic operators and operations
[Java] Difference between assignment of basic type variable and assignment of reference type variable
Difference between Not Null constraint and model validation (presence: true)
[Java] Difference between == and equals
Rails: Difference between resources and resources
Difference between puts and print
Difference between CUI and GUI
Difference between variables and instance variables
Difference between mockito-core and mockito-all
Difference between class and instance
Difference between bundle and bundle install
Connection between ViewModel and XML
Difference between ArrayList and LinkedList
Difference between render and redirect_to
Difference between List and ArrayList
Differences between IndexOutOfBoundsException and ArrayIndexOutOfBoundsException
Difference between .bashrc and .bash_profile
About Ruby and object model
Difference between StringBuilder and StringBuffer
JavaScript overview and basic grammar
Ruby methods and classes (basic)
Difference between render and redirect_to
Difference between render and redirect_to
[Ruby] Relationship between parent class and child class. The relationship between a class and an instance.
[Java] Introductory structure Class definition Relationship between class and instance Method definition format
The relationship between strict Java date checking and daylight savings time
About the relationship between the Java String equality operator (==) and initialization. Beginners