Cameron Cameron - 1 year ago 189
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?

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


If you need the matching to be case insensitive.

@items = { |item|[:q].downcase) }
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download