searchlogic and virtual attributes
- by Ermin
Let's say I have the following model:
Person <AR
def name
[self.first_name,self.middle_name,self.last_name].select{|n| n.present?}.join(' ')
end
end
How could I do a search on the virtual attribute with searchlogic, something like:
Person.search.name_like 'foo'
Of courese I could construct a large statement like:
Person.search.first_name_like_or_last_name_like_or_... 'argh'
but surely there is a more elegant way.