Created
March 28, 2019 10:14
-
-
Save MaryKuz/8c939121afb6eea91d626fd566f1edcb to your computer and use it in GitHub Desktop.
Correct the .search_by method
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
def search_by params = {} | |
params = params.try(:symbolize_keys) || {} | |
collection = page(params[:page]) | |
if params[:term].present? | |
collection = collection.where('name ILIKE ?', "#{ params[:term] }%") | |
end | |
if params[:name].present? | |
collection = collection.search(params[:name]) | |
end | |
collection | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment