Accessing MySQL Relationships with Ruby on Rails

How do you access MySQL relationship using RoR?

0


source to share


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


Your question is meaningless.



Rails works with ActiveRecord, which handles all sorts of complex database relationships. See AR documentation for details.

+1


source







All Articles