On Sep 13, 2006, at 10:37 AM, Nic Werner wrote:
>
> All,
> 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.
>
> Thanks,
>
> --
> - 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.
Cheers-
-Ezra
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---