Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Transfer hash parameters into symbols
class Product < ActiveRecord::Base
class << self
def search_by params = {}
params = params.try(:symbolize_keys) || {}
collection = all
if params[:term].present?
collection = collection.where('name ILIKE ?', "#{ params[:term] }%")
end
collection
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment