João Mateus João Mateus - 1 year ago 142
Ruby Question

Code works on local server but not on heroku

The below code searches for products on an app I'm building. In my local server the search can be made case insensitive but not on heroku

def index
if params[:q]
search_term = params[:q]
@products = Product.where("name LIKE ?", "%#{search_term}%")
@products = Product.all

how can i fix this? I need it to be case insensitive.

Many thanks in advance.

Answer Source

You could do something like:

search_term = params[:q].downcase


search_term = params[q:].upcase

thereby sanitizing the inputs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download