Sha256: 7151fe5357192c6613b6a1aad5a4d1882558d8fa29c9c5e15ec9528cd29339f3

Contents?: true

Size: 633 Bytes

Versions: 4

Compression:

Stored size: 633 Bytes

Contents

module Spina
  class ImageCollection < ApplicationRecord
    include ImageCollectable

    has_one :page_part, as: :page_partable
    has_many :image_collections_images, autosave: true
    has_many :images, through: :image_collections_images
    has_many :structure_parts, as: :structure_partable

    accepts_nested_attributes_for :images, allow_destroy: true

    def content
      self
    end

    alias_method :old_update_attributes, :update_attributes
    def update_attributes(attributes)
      self.images.clear if attributes.reject{|key,value| key == "id" }.blank?
      old_update_attributes(attributes)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spina-1.0.3 app/models/spina/image_collection.rb
spina-1.0.2 app/models/spina/image_collection.rb
spina-1.0.1 app/models/spina/image_collection.rb
spina-1.0.0 app/models/spina/image_collection.rb