Sha256: be933dff58ed7a678fde5cf84a3abb9590ad38945690b7887d8c2c74224e19b1

Contents?: true

Size: 461 Bytes

Versions: 7

Compression:

Stored size: 461 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!
      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

7 entries across 7 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/models/page_image.rb
pages_core-3.15.4 app/models/page_image.rb
pages_core-3.15.3 app/models/page_image.rb
pages_core-3.15.2 app/models/page_image.rb
pages_core-3.15.1 app/models/page_image.rb
pages_core-3.14.0 app/models/page_image.rb
pages_core-3.13.0 app/models/page_image.rb