Created
May 16, 2020 19:23
-
-
Save adcpe/a355bfc02b73f0ded92c3611b3a4baad to your computer and use it in GitHub Desktop.
This file contains hidden or 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 filtered_list(filter_name, filter_value) | |
puts "#{filter_name} - #{filter_value}" | |
query = %(SELECT name, type, city FROM restaurants\n) | |
if filter_name.nil? && filter_value.nil? | |
query << "ORDER BY name ASC;" | |
else | |
query << %(WHERE LOWER(#{filter_name}) LIKE '%#{filter_value}%' ORDER BY name ASC;) | |
end | |
response = @conn.exec(query).to_a | |
query_to_table(response) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment