Adding a finder method


#1

I have the following database scheme

[company]
id
name

[department]
id
name
company_id

[person]
id
name
company_id

[department_people]
id
staff_id
department_id

and my models

class Company < ActiveRecord::Base
has_many :departments
has_many :people
end

class Department < ActiveRecord::Base
has_many :people

end

class Person < ActiveRecord::Base
belongs_to :department_people
belongs_to :department, :through => :department_people
belongs_to :company
end

class DepartmentPeople < ActiveRecord::Base
belongs_to :company
belongs_to :person
end

So a person in a company can be in a department. I what to add a
finder method “get_available_staff” to my department model that
returns People that are in the company that the department is part of
(department.company_id = company.id) Can anyone point me in the right
direction ???

thanks RailsNewbie