João Mateus
João Mateus

Reputation: 115

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}%")
  else
    @products = Product.all
  end
end

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

Many thanks in advance.

Upvotes: 2

Views: 76

Answers (1)

Jeremy
Jeremy

Reputation: 745

You could do something like:

search_term = params[:q].downcase

or

search_term = params[q:].upcase

thereby sanitizing the inputs.

Upvotes: 1

Related Questions