Forum: Ruby on Rails Search/advanced search

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
17a97e09a1b23bc733ae22880a961b59?d=identicon&s=25 Mike (Guest)
on 2006-01-27 17:54
Hello,

How do you handle advanced searches in Rails, i.e., anything more than
one field?

I searched the archives but wasn't able to find a good example of this.
[I also noticed the forum itself has no advanced search yet!]

This is another of those common scenarios--like advanced lookup
functionality--that I'd address if I was inventing a Web framework.

I've been re-reading the Agile Rails book but couldn't find a discussion
of search functionality ("search" also isn't listed in the index).

I'm sure people are building search functionality and I'm just missing
something!
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-01-27 18:00
(Received via mailing list)
Mike wrote:
> Hello,
>
> How do you handle advanced searches in Rails, i.e., anything more than
> one field?
>
find_all_by_fielda_and_fieldb(vala,valb) will do it.

If it's more complex, you can use:
   find(:all, :conditions => ['foo=? and bar!=?', [vala, valb]])
17a97e09a1b23bc733ae22880a961b59?d=identicon&s=25 Mike (Guest)
on 2006-01-27 18:30
Hey Alex,

Thanks. I may be making this more complicated than it needs to be in
Rails.
25bbc96d9c53647354cb724e744b2222?d=identicon&s=25 Greg Freemyer (Guest)
on 2006-01-28 00:42
(Received via mailing list)
I'm a newbie but I think that is what Ferret is for.

On 1/27/06, Mike <no@spam.com> wrote:
>
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Greg Freemyer
The Norcross Group
Forensics for the 21st Century
This topic is locked and can not be replied to.