Hi,
Im a real newbie to ruby, but I have a bit of a background in php/mysql.
Ive been assigned work on a low profile, low priority project to help me
learn. So a lot of the tables are already defined and I probably
shouldnt change them at this stage.
I have a table of users:
Name, loginname, department_number(and more) this is already modeled
and working in the app
I have a table of departments
department_admin_loginname, department_number(and more) - this is an
existing table in a different database on the same ms sql server. It is
not a part of the app and is used by several other apps, so I really
cant alter it.
Departments can have more than one admin, and a user can be an admin of
more than one department. A user may belong to multiple departments,
thus having multiple department admins. I dont care what department you
are in.
All I need to know is when a user logs in, is the user an admin and who
are people he or she is an admin for. If the user is not an admin,
show who your admins are.
My first instinct was to create a view that joined up a few tables in a
couple of different databasesd order to produce a lookup table:
admin_loginname, user_loginname
When a user logs in, fire two quick queries: select user_loginname from
jointable where admin_loginname=myname and select admin_loginname from
jointable where user_loginname=byname. Bada-boom, bada-bing 4 lines of
php and Ive got your info ready to go. But I know how ruby people feel
about php. 
I think I understand how I would use has_many and belongs to if I were
connecting 2 different modeled objects. Customers and Orders come up a
lot in the examples. But in this case, a user can be associated with
many users based on that lookup table. The lookup table isnt really a
class that should be modeled, neither are any of the tables in the join
to produce the view.
Any ideas or pointers to examples?
Thanks!