0

I'm trying to do a search using,

Product.order(:name).where("name like ?", params[:term])

Where :term is in non latin characters (Hebrew). Both my application and my database are set to UTF-8 application.rb

config.encoding = "utf-8"

database

utf8_unicode_ci

and the specific name I'm searching is in the database, but the search comes out empty.

Any suggestions?

3
  • How many rows do you have in the table you're searching? If there are only a handful, that could be your issue.
    – user377628
    Jun 5, 2012 at 21:41
  • well for testing there is only one row and I search for exactly it but it won't find it :-(
    – gmaliar
    Jun 6, 2012 at 5:49
  • Yeah, I don't think that will work. Usually, when there is only 1-4 rows of data, not a whole lot will be returned on search. Try adding about 10 rows of unique data. Then try searching. Let me know what you get.
    – user377628
    Jun 6, 2012 at 5:52

1 Answer 1

0

I had to add % of my own in the params[:term:] So now it is

Product.order(:name).where("name like ?", params[:term]+"%")

I am not sure if this the best way to achieve what I wanted but it works nonetheless ...

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.