ability to share template with testing account

This commit is contained in:
Pete Matsyburka
2024-02-03 22:37:17 +02:00
parent 8630c68631
commit c67188edf8
25 changed files with 454 additions and 206 deletions
+1
View File
@@ -57,6 +57,7 @@ class Template < ApplicationRecord
class_name: 'ActiveStorage::Attachment', dependent: :destroy, as: :record, inverse_of: :record
has_many :submissions, dependent: :destroy
has_many :template_sharings, dependent: :destroy
scope :active, -> { where(archived_at: nil) }
scope :archived, -> { where.not(archived_at: nil) }
+28
View File
@@ -0,0 +1,28 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: template_sharings
#
# id :bigint not null, primary key
# ability :string not null
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
# template_id :bigint not null
#
# Indexes
#
# index_template_sharings_on_account_id_and_template_id (account_id,template_id) UNIQUE
# index_template_sharings_on_template_id (template_id)
#
# Foreign Keys
#
# fk_rails_... (template_id => templates.id)
#
class TemplateSharing < ApplicationRecord
ALL_ID = -1
belongs_to :template
belongs_to :account, optional: true
end