Not exactly the same thing but I think you can relate.

In an application I am working on right now I have 2 separate tables,
one for Roles (manager, worker, etc) and another one for Users
(people). I chose that design instead of keeping a list of roles in
the code because it keeps my application 'cleaner' in the sense that
if a new role is needed a person with enough authority to do so can
just add the new role to the DB through a maintenance page. The User
record has a column for 'role_id' that you can easily maintain also
through the user pages.

On Sep 11, 10:20 pm, Brian Ablaza <[email protected]> wrote:
> I have a People table and a Tasks table. Some People are Managers, some
> are Workers. Each Task has a Manager and a Worker.
>
> How do I define the relationships? I tried a STI setup, where Managers
> and Workers inherit from People, and People has a type column. In my
> Task table, I have worker_id and manager_id rows. Then:
>
> task belongs_to worker
> task belongs_to manager
> worker has_many tasks
> manager has_many tasks
>
> But when I ask for task.worker, or task.manager, it throws an error.
>
> How can I do this without separate Worker and Manager tables?
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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