On 13 September 2010 09:46, Michael Pavling <[email protected]> wrote:
> Alternatively, create two foreign keys in Tasks and link them both to
> the Person model:
>
> class Task < ActiveRecord::Base
>  belongs_to :worker, :foreign_key => "worker_id", :class_name => "Person"
>  belongs_to :manager, :foreign_key => "manager_id", :class_name => "Person"
> end

oh... and if you do have some criteria that determine who can be
assigned to be a manager or worker, then then you can add a
:conditions element too. So if you have a "people_permitted_to_manage"
table, you can join to that to filter the person_id values that can go
into manager_id in Task.

HTH

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to