Sha256: 56ddcdba34a8ba710690dfb74de2ee44357f50095f307d05d9f4dfb17916ecea

Contents?: true

Size: 465 Bytes

Versions: 21

Compression:

Stored size: 465 Bytes

Contents

# frozen_string_literal: true

class PageImage < ApplicationRecord
  include PagesCore::Sweepable

  belongs_to :page
  belongs_to_image :image

  accepts_nested_attributes_for :image
  validates_associated :image

  acts_as_list scope: %i[page primary]

  localizable

  class << self
    def cleanup!
      all.find_each do |page_image|
        page_image.destroy unless page_image.image
      end
    end
  end

  def image
    super.localize!(locale)
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pages_core-3.8.0 app/models/page_image.rb