In the article Search and Filter Rails Models Without Bloating Your Controller, the author described a way to filter records by multiple params:
params.slice(:status, :location, :starts_with).each do |key, value| @products = @products.public_send(key, value) if value.present? end
As an alternative, you can write:
This is for a newer Rails version.