Sha256: b4cd9f6fbeb331626fb8ec35c2bc0f66edac798feaa0dd2da391402826dda192

Contents?: true

Size: 740 Bytes

Versions: 21

Compression:

Stored size: 740 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
    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

21 entries across 21 versions & 1 rubygems

Version Path
effective_assets-1.6.3 app/models/effective/attachment.rb