Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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