module Elabs class Album < ApplicationContentRecord self.table_name = 'albums' ADDITIONAL_HABTM_COUNTER_CACHES = [ %w[projects albums] ].freeze validates :name, presence: true validates :description, presence: true validates_with AssociatedAuthorValidator, relations: %w[project upload] belongs_to :user belongs_to :license belongs_to :language has_many :albums_tags has_many :projects_albums has_many :albums_uploads has_many :tags, through: :albums_tags, dependent: :destroy has_many :projects, through: :projects_albums, dependent: :destroy has_many :uploads, through: :albums_uploads, dependent: :destroy has_many :comments, as: 'content' end end