Created
March 28, 2019 09:52
-
-
Save MaryKuz/59a0098211f2848534c2ae8cbc54a933 to your computer and use it in GitHub Desktop.
Transfer hash parameters into symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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