views:

246

answers:

2

How do you access a MySQL relation using RoR?

+1  A: 

Your question doesn't really make sense.

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

Toby Hede
+3  A: 

Toby is right. You need to learn about table relationships using ActiveRecord.

The gist. You need to put the following codes in your models. Here is an example.

In User model:

has_many :addresses

In the Address model:

belongs_to :user

This is for a one to many relationship.

This guide should give you all the help you need.

You can also refer to the rails documentation by going to this site and enter 'belongs_to' in the search box. That will bring you to the relevant page.

allesklar