Sha256: 11cddd829fafc720ea25f5fa1717c03d2f68d56d3d206781094fca306db6422c

Contents?: true

Size: 861 Bytes

Versions: 1

Compression:

Stored size: 861 Bytes

Contents

module Elabs
  class Upload < ApplicationContentRecord
    self.table_name = 'uploads'

    ADDITIONAL_HABTM_COUNTER_CACHES = [
      %w[albums uploads],
      %w[projects uploads]
    ].freeze

    validates :title,           presence: true
    validates :description,     presence: true
    validates :file_attachment, presence: true
    validates_with AssociatedAuthorValidator, relations: %w[album project]

    belongs_to :user
    belongs_to :license
    belongs_to :language
    has_many :uploads_tags
    has_many :projects_uploads
    has_many :albums_uploads
    has_many :tags,     through: :uploads_tags,     dependent: :destroy
    has_many :projects, through: :projects_uploads, dependent: :destroy
    has_many :albums,   through: :albums_uploads,   dependent: :destroy
    has_many :comments, as: 'content'

    has_one_attached :file
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elabs-2.0.0.pre app/models/elabs/upload.rb