Sha256: 0d845247c17ac572e9add3d2b2d81db187607707ac66f8587169baad82cca781

Contents?: true

Size: 913 Bytes

Versions: 3

Compression:

Stored size: 913 Bytes

Contents

# <%= autogenerated_model_warning %>

class Account < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable
  # include CanvasSync::Concerns::Account::Ancestry # Add support for the ancestry Gem

  validates :canvas_id, uniqueness: true, presence: true

  has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_account_id
  belongs_to :canvas_parent, class_name: 'Account', optional: true,
                             primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
  has_many :sub_accounts, class_name: 'Account',
                          primary_key: :canvas_id, foreign_key: :canvas_parent_account_id
  has_many :groups, primary_key: :canvas_id, foreign_key: :canvas_account_id

  api_syncable({
    name: :name,
    workflow_state: :workflow_state,
    canvas_parent_account_id: :parent_account_id,
  }, -> (api) { api.account(canvas_id) })
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canvas_sync-0.15.1 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.15.0 lib/canvas_sync/generators/templates/models/account.rb
canvas_sync-0.14.0 lib/canvas_sync/generators/templates/models/account.rb