airtable_sync 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -13
- data/lib/airtable_sync/version.rb +1 -1
- data/lib/airtable_sync.rb +0 -6
- metadata +1 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57ef6a46048952c273adf2104f58df8f549228f92176ef1d640806553d233fdd
|
4
|
+
data.tar.gz: 12f22c78538055e00367a6e69d9eb7693c3f788f97483b38441581695eeec4d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86f58cbd861fa04d2dce488ba1f850c264ea904ddd0e878fef7597eca4f1f6c0d53ef4c1ad200db2f3438c2f4d5f204bc63d7532cef0fdce7c6252704437fc14
|
7
|
+
data.tar.gz: 705ef73ead60b13d593e6927ae320a28d82f236c673e361e1377d27b156322e8eef19d65c24e4db37eba00746f29b1da877e6a9b2debe5961f0b9c57a8edd9ab
|
data/README.md
CHANGED
@@ -13,9 +13,12 @@ For the latest changes, see the [CHANGELOG.md](CHANGELOG.md).
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
15
|
```ruby
|
16
|
+
gem 'airrecord', github: 'vfonic/airrecord'
|
16
17
|
gem 'airtable_sync'
|
17
18
|
```
|
18
19
|
|
20
|
+
We need to use airrecord fork because the original gem is unfortunately poorly maintained by AirTable and community and I don't have the resources to maintain it myself.
|
21
|
+
|
19
22
|
And then execute:
|
20
23
|
|
21
24
|
```bash
|
@@ -30,17 +33,13 @@ bundle exec rails generate airtable_sync:install
|
|
30
33
|
|
31
34
|
## Usage
|
32
35
|
|
33
|
-
1. Generate AirTable API key
|
34
|
-
https://airtable.com/create/apikey
|
35
|
-
2.
|
36
|
-
|
37
36
|
### Configuration options
|
38
37
|
|
39
38
|
In `config/initializers/airtable_sync.rb` you can specify configuration options:
|
40
39
|
|
41
|
-
1. `api_key`
|
42
|
-
2. `
|
43
|
-
3. `skip_airtable_sync` -
|
40
|
+
1. `api_key` - In order to use this gem, you need to generate AirTable API key: https://airtable.com/create/apikey
|
41
|
+
2. `airtable_base_id` - you can set `airtable_base_id` here or override `def airtable_base_id` in your model. More on this below.
|
42
|
+
3. `skip_airtable_sync` - if set to `true`, AirtableSync will not sync records to AirTable. This is useful for development and test environments where you don't want to sync records to AirTable.
|
44
43
|
|
45
44
|
Example:
|
46
45
|
|
@@ -51,6 +50,10 @@ AirtableSync.configure do |config|
|
|
51
50
|
end
|
52
51
|
```
|
53
52
|
|
53
|
+
### Create AirTable tables
|
54
|
+
|
55
|
+
You need to create the AirTable base(s) and table(s) yourself.
|
56
|
+
|
54
57
|
### Add AirtableSync to models
|
55
58
|
|
56
59
|
For each model that you want to sync to AirTable, you need to run the connection generator:
|
@@ -61,10 +64,6 @@ bundle exec rails generate airtable_sync:connection Article
|
|
61
64
|
|
62
65
|
Please note that this _does not_ create the AirTable table. You need to already have it or create it manually.
|
63
66
|
|
64
|
-
### Create AirTable tables
|
65
|
-
|
66
|
-
As mentioned above, you need to create the AirTable tables yourself.
|
67
|
-
|
68
67
|
### Set `airtable_base_id`
|
69
68
|
|
70
69
|
There are couple of ways how you can set the `airtable_base_id` to be used.
|
@@ -79,6 +78,20 @@ AirtableSync.configure do |config|
|
|
79
78
|
end
|
80
79
|
```
|
81
80
|
|
81
|
+
#### Set `airtable_base_id` in model
|
82
|
+
|
83
|
+
```rb
|
84
|
+
# app/models/article.rb
|
85
|
+
|
86
|
+
class Article < ApplicationRecord
|
87
|
+
include AirtableSync::RecordSync
|
88
|
+
|
89
|
+
def airtable_base_id
|
90
|
+
site.airtable_base_id
|
91
|
+
end
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
82
95
|
### Customize fields to synchronize
|
83
96
|
|
84
97
|
By default, AirtableSync calls `#as_airtable_json` on a record to get the fields that it needs to push to AirTable. `#as_airtable_json` simply calls `#as_json` in its default implementation. To change this behavior, you can override `#as_airtable_json` in your model:
|
@@ -122,10 +135,10 @@ For example:
|
|
122
135
|
AirtableSync::CreateRecordJob.perform_now('articles', 1, 'Stories')
|
123
136
|
```
|
124
137
|
|
125
|
-
Or, if you want to use the default '
|
138
|
+
Or, if you want to use the default 'Articles' table name:
|
126
139
|
|
127
140
|
```ruby
|
128
|
-
AirtableSync::CreateRecordJob.perform_now('articles', 1)
|
141
|
+
AirtableSync::CreateRecordJob.perform_now('articles', 1) # table_name defaults to 'Articles'
|
129
142
|
```
|
130
143
|
|
131
144
|
### Run the initial sync
|
data/lib/airtable_sync.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airtable_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Viktor
|
@@ -10,20 +10,6 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: airrecord
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rails
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|