Wow this is a very clean approach. Trying this one out. :-)

Thanks heaps.

On Mar 1, 12:35 pm, Michael Graff <skan.gryp...@gmail.com> wrote:
> I often do the brute-force approach:
>
>   cond_string = []
>   cont_hash = {}
>
>   if params[:search_name]
>     cond_string << "(name ILIKE :name)"
>     cond_hash[:name] = "%#{params[:search_name]}%"
>   end
>   if params[:search_address]
>     cond_string << "(address ILIKE :name)"
>     cond_hash[:address] = "%#{params[:search_address]}%"
>   end
>
> conditions = cond_string.join(" AND ")
> Person.all :conditions => [ conditions, cond_hash ]

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to