Associations question

Hey everyone,

I have a quick question on a tricky model for the app I'm working on. I have a Tasks model, and a Task can be assigned to a User; a Task should also know the User who assigned (created) it, and be updatable by that user. The idea is so the View can have something like on a "My Tasks" page:

Assigned by John Smith on June 1st, 2008

Since it has to have two references to the same model (User), one for who has been assigned to, and one for who did the assigning, what association should I be looking at? The associations in Rails are a little confusing beyond the basic belongs_to/has_one/has_many things, so I'm not sure what I should use. has_and_belongs_to_many? has_many :through?

Any help would be appreciated.

- Wayne

fields in tasks: user_id and assigning_user_id

in the task model:

belongs_to :user
belongs_to :assigning_user, :class => “User”

in the user model:

has_many :tasks
has_many :assigned_tasks, :as => “assigning_user”

fields in tasks: user_id and assigning_user_id

in the task model:

belongs_to :user
belongs_to :assigning_user, :class => "User"

in the user model:

has_many :tasks
has_many :assigned_tasks, :as => "assigning_user"

that should be :foreign_key => "assigning_user_id".
I wrote up a reasonably detailed walkthrough of this sort of thing at http://spacevatican.org/2008/5/6/creating-multiple-associations-with-the-same-table

Fred

I'll check that link out - thanks all!

- Wayne