Forum: Ruby on Rails Problem with paginate search

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jean Carlo Schechnner (Guest)
on 2006-03-01 18:34
(Received via mailing list)
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
KW (Guest)
on 2006-03-02 01:34
(Received via mailing list)
Jean Carlo Schechnner <identidadvirtual@...> writes:

>
> Hi,Firts all sorry for my poor englishI 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 =
 <at> params['search'].to_s.split(' ')   array_conditions = []   for w
in words
>      array_conditions = array_conditions + ["business LIKE '%#{w}%'"]   end
conditions = 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 ')
  ...
Neil D. (Guest)
on 2006-03-02 02:31
(Received via mailing list)
Jean Carlo Schechnner wrote:
>    array_conditions = []
> 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.
This topic is locked and can not be replied to.