MySQL syntax in Rails 3, case-insensitive search, not working on Heroku?

I am following Railscast for adding search, sorting and pagination in my application. I changed my search logic in the column search model (description and name). It seems to work. I also modified it to look for case insensitive. This seems to work fine in my local application, but when I click on the hero I can only search for lowercase letters. A search with any uppercase letters does not return results at all, even if the case matches the results.

here is the code in my model:

  def self.search(search)
    if search
      where('LOWER (description) LIKE ? OR LOWER (title) LIKE ?', "%#{search}%" , "%#{search}%")
    else
      scoped
    end
  end
+5
source share
2 answers

Try

where("LOWER (description) LIKE ? OR LOWER (title) LIKE ?", "%#{search.downcase}%" , "%#{search.downcase}%")
+5
0

All Articles