Skip to content

Instantly share code, notes, and snippets.

@MaryKuz
Created March 28, 2019 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryKuz/59a0098211f2848534c2ae8cbc54a933 to your computer and use it in GitHub Desktop.
Save MaryKuz/59a0098211f2848534c2ae8cbc54a933 to your computer and use it in GitHub Desktop.
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