Thread View: pl.comp.lang.ruby
1 messages
1 total messages
Started by Sławek Tuleja
Fri, 28 Mar 2008 18:58
RoR live search
Author: Sławek Tuleja
Date: Fri, 28 Mar 2008 18:58
Date: Fri, 28 Mar 2008 18:58
21 lines
1744 bytes
1744 bytes
Witam
W ksiazce Rails Cookbook jest przedstawiony przyklad live search.
Jest jedno pole tekstowe do ktorego wpisujemy szukane slowo (slowa) w
kolumnie 'title'.
def self.search(terms)
find :all,
:conditions => [(["(LOWER(title) LIKE ?)"] *
terms.size ).join(" AND "), * terms.flatten]
end
# terms to tablica zawierajaca wpisane slowa
Moje pytanie jest nastepujace:
Jak nalezy zdefiniowac funkcje search, aby za pomoca jednego pola
tekstowego wpisane slowo (slowa) byly wyszukiwane nie tylko w jednej
kolumnie bazy, ale w kilku kolumnach np. 'title', 'body' itp ...
Swietnym przykladem jest live search na www.gotapi.com
pozdrawiam
Sławek
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads