Wildcard Query (revisited)

With the advent of plugins like ez_where and such, is there a “best
practice” way to do perform a LIKE query with wildcards? The archives
show some hacks, but I haven’t seen this issue in a while and I’d like
to know if there is a clean way.

Looking for: select * from table_a where name like %search_param%

and search_attr is a passed param.


  • Nic

On Sep 13, 2006, at 10:37 AM, Nic W. wrote:


  • Nic

Hey Nic-

Stuff like that is very easy with ez-where. Something like this:

Assume your model is named User

@users = User.find_where(:all) { |user| user.name =~ ‘%params
[:querystring]%’ }

There are a ton of examples in the 1000line+ test suite that

exercise all the things you can do with the plugin.