From 3cc21eaf699be2eec2c0c135c042f61508cff878 Mon Sep 17 00:00:00 2001 From: Alexander Sorokin Date: Tue, 15 Nov 2016 10:26:35 -0800 Subject: [PATCH 1/2] Use proper escape --- lib/airtable/table.rb | 9 ++++++++- lib/airtable/version.rb | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/airtable/table.rb b/lib/airtable/table.rb index 2205db8..82dc903 100644 --- a/lib/airtable/table.rb +++ b/lib/airtable/table.rb @@ -109,7 +109,14 @@ def result_attributes(res) end def worksheet_url - "/#{app_token}/#{CGI.escape(worksheet_name)}" + "/#{app_token}/#{url_encode(worksheet_name)}" + end + + # From http://apidock.com/ruby/ERB/Util/url_encode + def url_encode(s) + s.to_s.dup.force_encoding("ASCII-8BIT").gsub(/[^a-zA-Z0-9_\-.]/) { + sprintf("%%%02X", $&.unpack("C")[0]) + } end end # Table diff --git a/lib/airtable/version.rb b/lib/airtable/version.rb index e8724ec..019ad9a 100644 --- a/lib/airtable/version.rb +++ b/lib/airtable/version.rb @@ -1,3 +1,3 @@ module Airtable - VERSION = "0.1.0" + VERSION = "0.1.1" end From 15936caff3bf91da1cd5d0a7becf0184f51767ef Mon Sep 17 00:00:00 2001 From: Rohan Date: Wed, 13 Jun 2018 12:52:55 +0530 Subject: [PATCH 2/2] Added documentation for select method as it was missing --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 8fb0a0c..0d06276 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,15 @@ We can also query all records in the table through a series of batch requests wi This executes a variable number of network requests (100 records per batch) to retrieve all records in a sheet. +We can also use `select` method to query based on specific conditions using `formula` parameter + +```ruby +@records = @table.select(sort: ["Order", "asc"], formula: "Active = 1") +``` + +This will return all the records that has `Active` column value as `true` from table. + + ### Finding a Record Records can be queried by `id` using the `find` method on a table: