I've been following the Railscast for adding searching, sorting, and pagination to my app. I've modified my search logic in the model to search to columns (description and title). This seems to be working. I've also changed it to search non case sensitive. This seems to work perfect in my local app, but when I push it to heroku, I can only search by lowercase. Search with any capital letters at all produces no results, 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
Try
where("LOWER (description) LIKE ? OR LOWER (title) LIKE ?", "%#{search.downcase}%" , "%#{search.downcase}%")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With