Class: AirtableSync::InitialSyncJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/airtable_sync/initial_sync_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(table_name) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/jobs/airtable_sync/initial_sync_job.rb', line 5

def perform(table_name)
  model_class = table_name.underscore.classify.constantize
  model_class.where(airtable_id: nil).find_each do |record|
    next if record.airtable_base_id.blank?

    client(record.airtable_base_id).create_record(record, table_name)
  end
end