Trying to implement a search logic search that uses associations with STI but I’m having a problem where it is not select the STI records as the subclass but the parent.
Example:
class Users
end
class Artist < User has many :agents, :through => :agents artists end
class Agent < User has many :artists, :through => :agents artists end when i do a search for "artist agents company like", it is searching based on the agents as users rather than as agents:
select * from users WHERE users.company LIKE
rather than
select * from users AS agents WHERE agents.company LIKE
Wondering if I can pre-empt this problem at the ActiveRecord class level (eg in the association I was thinking that if you could specify that the agents would get loaded :as=>:agent or something along those lines), or if I would need to patch searchlogic or what else I could do to accomplish this.
One other option that occurred to me, and I dread the idea, is to add a field on the user table that includes a listing of the person’s agencies. eg users.agencies => Agency One Name,Agency Two Name