Storing Resource as Model

Record-Oriented Data

Data whose attribute is different from each other but with the same structure.

If we want to store the data permanently, it has to live somewhere outside the programming language.

We should convert it between data as stored and data as manipulating.
In Rails, it shall use relationship database like SQL.

Active Record

Create != new, but new and save

.save! and .create! will throw exceptions once saving is failed.

Read

Update and Delete

Summary

update is used more often now!

Summary about Active Record

What’s new in Rails >= 5 Hierarchy is good for managing classes common methods and attributes.

Database and Migration


schema.rb is a executable file which re-create the schema in another database.

Create:

Change:

Summary