Accessing MySQL Relationships with Ruby on Rails
2 answers
Toby is right. You need to learn about table relationships with ActiveRecord.
The essence . You need to put the following codes in your models. Here's an example.
In the user model:
has_many :addresses
In the Address model:
belongs_to :user
It is a one to many relationship.
This guide should provide you with all the help you need.
You can also refer to the rails documentation by going to this site and typing "own_to" in the search box. This will take you to the corresponding page.
+3
source to share