Hi, Firts all sorry for my poor english I am doing a simple search with paginate, the problem is the search dont find the words within acutes (example "dont find sal?n if i search salon"). Its the code for the seach: def search words = @params[''search''].to_s.split('' '') array_conditions = [] for w in words array_conditions = array_conditions + ["business LIKE ''%#{w}%''"] end conditions = array_conditions.join('' AND '') @business_pages, @businesses = paginate :businesses, :per_page => 10, :conditions => conditions end Thanks for you help Jean Carlo Schechnner -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060301/976a3ce0/attachment.html
Jean Carlo Schechnner <identidadvirtual@...> writes:> > Hi,Firts all sorry for my poor englishI am doing a simple search withpaginate, the problem is the search dont find the words within acutes (example "dont find> sal?n if i search salon"). Its the code for the seach: def search words <at> params[''search''].to_s.split('' '') array_conditions = [] for w in words > array_conditions = array_conditions + ["business LIKE ''%#{w}%''"] endconditions = array_conditions.join('' AND '')> <at> business_pages, <at> businesses = paginate :businesses, :per_page =>10, :conditions => conditions endThanks for you helpJean Carlo Schechnner>I don''t think this is a problem with your code... it''s probably because the database engine doesn''t think that ''sal?n'' is LIKE ''salon''. BTW, this might be a bit more classic Ruby style: def search conditions = @params[''search''].to_s.split('' '').collect {|word| "business LIKE ''%#{word}%''"}.join('' AND '') ...
Jean Carlo Schechnner wrote:> Hi, > > Firts all sorry for my poor english > > I am doing a simple search with paginate, the problem is the search dont > find the words within acutes (example "dont find sal?n if i search > salon"). Its the code for the seach: > > def search > words = @params[''search''].to_s.split('' '') > array_conditions = [] > for w in words > array_conditions = array_conditions + ["business LIKE ''%#{w}%''"] > end > conditions = array_conditions.join('' AND '') > @business_pages, @businesses = paginate :businesses, :per_page => 10, > :conditions => conditions > end > > Thanks for you help > > Jean Carlo Schechnner > >This probably isn''t doesn''t to have anything to do with RoR but on how the database is handling the query generated by the above code. What database are you using? It probably doesn''t think "sal?n" = "salon" You will probably find its how the database handles the ''LIKE'' search. You might be able to configure your database differently to handle this. Regards Neil.