From: Ira W. Snyder Date: Tue, 27 Nov 2007 03:12:53 +0000 (-0800) Subject: Fix LIKE clauses in searches to match anywhere in the field X-Git-Tag: turned-in~11 X-Git-Url: https://www.irasnyder.com/gitweb/?a=commitdiff_plain;h=de5e46c88f07fd828548ab7226cb7a0c5ebe59d5;p=cs356-p2-videostore.git Fix LIKE clauses in searches to match anywhere in the field Signed-off-by: Ira W. Snyder --- diff --git a/app/controllers/customer_controller.rb b/app/controllers/customer_controller.rb index 296f64f..f6ec048 100644 --- a/app/controllers/customer_controller.rb +++ b/app/controllers/customer_controller.rb @@ -56,7 +56,7 @@ class CustomerController < ApplicationController def search if request.post? @query = params[:q] - @customers = Customer.find(:all, :conditions => ["name like ?", @query[0]+"%"]) + @customers = Customer.find(:all, :conditions => ["name like ?", "%#{@query[0]}%"]) render :action => 'searchresults' else render :action => 'search' diff --git a/app/controllers/game_controller.rb b/app/controllers/game_controller.rb index c75ce07..626d51a 100644 --- a/app/controllers/game_controller.rb +++ b/app/controllers/game_controller.rb @@ -56,7 +56,7 @@ class GameController < ApplicationController def search if request.post? @query = params[:q] - @games = Game.find(:all, :conditions => ["title like ?", @query[0]+"%"]) + @games = Game.find(:all, :conditions => ["title like ?", "%#{@query[0]}%"]) render :action => 'searchresults' else render :action => 'search' diff --git a/app/controllers/video_controller.rb b/app/controllers/video_controller.rb index 2451704..34678fc 100644 --- a/app/controllers/video_controller.rb +++ b/app/controllers/video_controller.rb @@ -56,7 +56,7 @@ class VideoController < ApplicationController def search if request.post? @query = params[:q] - @videos = Video.find(:all, :conditions => ["title like ?", @query[0]+"%"]) + @videos = Video.find(:all, :conditions => ["title like ?", "%#{query[0]}%"]) render :action => 'searchresults' else render :action => 'search' diff --git a/db/development.sqlite3 b/db/development.sqlite3 index 694afec..88be064 100644 Binary files a/db/development.sqlite3 and b/db/development.sqlite3 differ