searchlogic and virtual attributes

Posted by Ermin on Stack Overflow See other posts from Stack Overflow or by Ermin
Published on 2010-05-10T07:50:18Z Indexed on 2010/05/10 7:54 UTC
Read the original article Hit count: 384

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about searchlogic