From de5e46c88f07fd828548ab7226cb7a0c5ebe59d5 Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Mon, 26 Nov 2007 19:12:53 -0800 Subject: [PATCH] Fix LIKE clauses in searches to match anywhere in the field Signed-off-by: Ira W. Snyder --- app/controllers/customer_controller.rb | 2 +- app/controllers/game_controller.rb | 2 +- app/controllers/video_controller.rb | 2 +- db/development.sqlite3 | Bin 30720 -> 30720 bytes 4 files changed, 3 insertions(+), 3 deletions(-) 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 694afec03596fa3cefdee87a443d4e7ce92da64b..88be0641845a2809992785a735488a807acc0887 100644 GIT binary patch delta 1181 zcma)*KTH#06u`gty=$+PD=k_B#X_&-IBJ#J7J;Zl6B7TRMUbNMPs0JHg#aaO88lH~ zGY$ki24@Ch90>K0!GX~@850>WCJZdb!~q?gG#HM?>PXm#YP{uElHV0{7OgX)Q~FuPrn5-B9!0}SPvOh5h3)K&UFZK8A*Zj* zzkLJ4=!Sknv^pG7hMWzI)>(t{+*xtbZZ(`5BdYaQ{K>!>%&4&@{KCa>p<>cOa1Ec~ zB(~#mw9*Z2GSjq=*3m-PgjX;P31|c_`A*)F1tok*q++KsUE--VRpqe>9d>dI{Gb&S zlQQxJS#BLq^(UmXY|?Dv&D=?+2{D{_BgZC83_Zg2y|Nj@iq?6A_I+3mA-)d_0z%t9 zGz?x-7E8S@Qxz0IY|VFNg6Imi>=fMy;?-TE5NzHlY8ivE|3LA|uG3cW@-8NdO*!T; zms6=)ePCe$KjV8`Rg0JU?0JCT+)8KzU)*R283IC&E51xaAHrsPZJ7qV)srKV8pH*bDO+UyF;tCh%75? zFOM5!d3Ne?Q$RdG4xe#q8vqxj5xG4f^YOuv^l3hx86UXE$K`Z-FgbdMWy>lxv+}Rm zEM*dWP11YAB8aKH$nFSblnCuvsJ~3Tk+Qu}4sfsCvc^Q)(a|d%4 zvk$W#6C7-8yurxDtjA!($f&5uC_H%szlaTxD+l7T2pSm}nCluE>Kd8BS(Y+lYz!b- z9!a{@VJZwPVJt(F$$I?qoRSbT7&$=}PR`=DVUZDKW0<^(UrB*W z2&UG^6wWdS`V8zQMyAOJ_(V1ducVZ~k$%*-D_fy=@CoB12_N1$1cm^XjX-z-1b(O+@%3I9n+U_QpYfq4