Cameron Cameron - 1 month ago 7x
Ruby Question

Ruby select from array where key is like parameter

I have a list of objects that I want to filter by a parameter in the URL.

So for example:

@items = { |item| params[:q] == }

However this will match EXACT... how can I make it behave as a LIKE?

@items = { |item|[:q]) }


If you need the matching to be case insensitive.

@items = { |item|[:q].downcase) }