Sha256: 8f49c8adde2cdf43ba1e8ff5bac53fe8c9553ceaeffc09a64870cc0678eecff1

Contents?: true

Size: 772 Bytes

Versions: 3

Compression:

Stored size: 772 Bytes

Contents

# This is a join table for assets and acts_as_attachable

module Effective
  class Attachment < ActiveRecord::Base
    self.table_name = EffectiveAssets.attachments_table_name.to_s

    belongs_to :asset, class_name: 'Effective::Asset'
    belongs_to :attachable, :polymorphic => true

    # structure do
    #   position        :integer
    #   box             :string, :default => 'assets'  # This is essentially a category
    # end

    default_scope -> { includes(:asset).order("\"#{EffectiveAssets.attachments_table_name.to_s}\".\"position\" ASC, \"#{EffectiveAssets.attachments_table_name.to_s}\".\"asset_id\" ASC") }

    validates :asset_id, presence: true
    validates :position, presence: true, numericality: true
    validates :box, presence: true

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
effective_assets-1.9.7 app/models/effective/attachment.rb
effective_assets-1.9.6 app/models/effective/attachment.rb
effective_assets-1.9.5 app/models/effective/attachment.rb