views:

23

answers:

1

in my rails app, I have an Organization model, with a reference to a User, which I want to be able to access via organization_instance.adminstrator. I'm not sure how to accomplish this using the belongs_to method.

+1  A: 

Nevermind. The proper solution (as I found it), is to do the following:

belongs_to :administrator, :class_name => "User"

interesting what reading the documentation can do for you :D

However, this poses a new question which is not directly apparent from the documentation: How do I generate the migration for this? Would

t.references :user

or

t.references :administrator

be the correct way?

Cody Haines
Either one, if you have a preference, but if you want that association definition to work as is, then the second. Crazy what you can learn reading the docs.
floyd