Reputation: 13835
I have some nifty javascript that serializes search input.
the controller has this:
@recipes = Recipe.where(name: params[:q])
right now it only returns results when theres an exact full word match - does anyone know of a way to make it return results which might contain the params[:q] even if its not an exact full match?
i.e. chicken should return chicken stew, chicken pot pie, etc.
Upvotes: 1
Views: 599
Reputation: 230286
Try this one:
@recipes = Recipe.where(name: /#{params[:q]}/i)
Upvotes: 3