Sha256: a4258263ec3263b08720eb9ae8b2f142c6968067878bbe0c0f77e775f44d301a

Contents?: true

Size: 522 Bytes

Versions: 4

Compression:

Stored size: 522 Bytes

Contents

module Spina
  class Image < ApplicationRecord
    belongs_to :media_folder, optional: true

    has_one_attached :file

    has_many :page_parts, as: :page_partable
    has_many :structure_parts, as: :structure_partable

    scope :sorted, -> { order('created_at DESC') }
    scope :sorted_by_image_collection, -> { order('position') }

    def name
      file.try(:filename).to_s
    end

    def variant(options)
      file.attached? ? file.variant(options) : ""
    end

    def content
      self
    end
 
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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