I am using single table inheritance which looks something like this:
class Employee < ActiveRecord::Base
Manager < Employee
Programmer < Employee
When I call Manager.find(…) or Programmer.find(…) regardless of
what parameters are passed to find I only want that employee type to
be returned. So Prgrammers.find(:all) will return all programmers, but
I somehow need to inject a condition “member_type = xxx” into every
find query of the Employee subclass.
I would like to be able to do it without any restrictions on calling
find. So find(:first), find(id) and find(:all) will all work.
Has anyone done this before or can point me in the right direction?