Not an odd request at all :-)
You want to look online for "rails self referential associations"
But essentially, in your User model add:
belongs_to :author, :class_name => "User"
and add a migration for the author_id field to be added to the users table.
> You want to look online for "rails self referential associations"
>
> But essentially, in your User model add:
> belongs_to :author, :class_name => "User"
>
> and add a migration for the author_id field to be added to the users table.
I think one of us (maybe more!) has misinterpreted what Marcos wanted.
I think he wants to do that on Posts, not Users. That way, each User
can post Posts from many different Authors, rather than each User
being able to attribute things to only one Author ever.
-Dave
--
Dave Aronson: Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com
Ah yes, sorry, I've galloped through and grabbed the wrong end of the
stick. Here's another gallop :-)
# posts model
belongs_to :user
belongs_to :author, :class_name => "User"
and add a migration for the author_id field to be added to the posts table.
Same principle of changing the class_name for the association - just
putting it on the right model this time! :-D