I've started using the metasearch gem http://metautonomo.us/projects/metasearch/ for a ruby on rails 3 app after seeing it recommended in another stackoverflow post. I would like to have a single text field on a search form that can search in multiple fields rather than have one text field for each. I just havn't been able to figure it out.
My example below is probably a little more complicated because it also uses Multi-level associations:
Model: Report belongs to site
Model: Site has many reports
View (the index for reports with a search form):
Have something like:
<%= f.text_field :site_name_or_site_address_contains %>
rather than 2 seperate text fields like:
<%= f.text_field :site_name_contains %>
<%= f.text_field :site_address_contains %>
The notes on the website and rdocs cover adding new where statements in the initializer. I'm not sure if thats required but I don't really understand them either.
Check out the latest version on GitHub: http://github.com/ernie/meta_search
I've held off on adding that support for a while because I think the syntax gets a bit goofy looking. You might want to check out the support for custom search methods, as well.
For those reading this, the functionality is in meta_search now - it works well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With