What did we just do?
We created two models named Tag and Destinations.
In the model files, we used the methods
belongs_to define an association between Tag and Destination:
has_many :destinations denotes that a single Tag can have multiple Destinations.
belongs_to :tag denotes that each Destination belongs to a single Tag.
belongs_to pair is frequently used to define one-to-many relationships. A few examples are:
- a Library has many Books; a Book belongs to a Library
- an Album has many Photos; a Photo belongs to an Album
- a Store has many Products; a Product belongs to a Store