Sha256: 6de6890f1bbdcd6dee7744630a72faa761c326817c08f11832b1d2753ee3905a

Contents?: true

Size: 698 Bytes

Versions: 1

Compression:

Stored size: 698 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, :validates => [:presence, :numericality]
      box             :string, :default => 'assets', :validates => [:presence]  # This is essentially a category
    end

    validates_presence_of :asset_id

    #attr_accessible :box, :position, :asset_id, :attachable_type, :attachable_id

    class << self
      def default_scope
        includes(:asset).order(:position)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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