in my rails app, I have an Organization model, wi开发者_StackOverflowth 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.
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?
精彩评论