Rails, search item in different model?
- by Danny McClelland
Hi Everyone,
I have a kase model which I am using a simple search form in. The problem I am having is some kases are linked to companies through a company model, and people through a people model.
At the moment my search (in Kase model) looks like this:
# SEARCH FACILITY
def self.search(search)
search_condition = "%" + search + "%"
find(:all, :conditions => ['jobno LIKE ? OR casesubject LIKE ? OR transport LIKE ? OR goods LIKE ? OR comments LIKE ? OR invoicenumber LIKE ? OR netamount LIKE ? OR clientref LIKE ? OR kase_status LIKE ? OR lyingatlocationaddresscity LIKE ?', search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition, search_condition])
end
What I am trying to work out, is what condition can I add to allow a search by Company or Person to show the cases they are linked to.
@kase.company.companyname
and
company.companyname
don't work :(
Is this possible?
Thanks,
Danny