Hello Ruth,
Try something like the following:
Assuming the title_search isn't provided by the user (no possibility of SQL injection attack exists):
def self.search_results(title_search)
find(:all,
:conditions => "title like '%#{title_search}%'",
:order => "title")
end
OR if the possibility of SQL injection attack exists:
def self.search_results(title_search)
find(:all,
:conditions => ["title like '%?%'", title_search] ,
:order => "title")
end
In the latter, the first question mark will be replaced (and slashed) by the second parameter, the second question mark by the third parameter and so on and so forth.
Hope this helps!
Upcoming books:
Pro Rails and Pro Server Management
Come attend my Applied ROR session in the MySQL UC.
My Grande RSS Feed (ROR + MySQL + Linux)
http://feedshake.com/mpfeeds/gk4zwwligo.xml
My blogs:
http://railsruby.blogspot.com
http://mysqldatabaseadministration.blogspot.com
Edited 1 time(s). Last edit at 03/23/2006 09:14PM by Frank Mash.