Sha256: b6c380e90f4272e87a8ed93271380159212b79f42bc66c3148e41bc8e0e7aac7

Contents?: true

Size: 702 Bytes

Versions: 35

Compression:

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

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

    validates_presence_of :asset_id

  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
effective_assets-1.4.2 app/models/effective/attachment.rb
effective_assets-1.4.1 app/models/effective/attachment.rb
effective_assets-1.4.0 app/models/effective/attachment.rb
effective_assets-1.3.2 app/models/effective/attachment.rb
effective_assets-1.3.1 app/models/effective/attachment.rb
effective_assets-1.3.0 app/models/effective/attachment.rb
effective_assets-1.2.5 app/models/effective/attachment.rb
effective_assets-1.2.4 app/models/effective/attachment.rb
effective_assets-1.2.3 app/models/effective/attachment.rb
effective_assets-1.2.2 app/models/effective/attachment.rb
effective_assets-1.2.0 app/models/effective/attachment.rb
effective_assets-1.1.2 app/models/effective/attachment.rb
effective_assets-1.1.1 app/models/effective/attachment.rb
effective_assets-1.1.0 app/models/effective/attachment.rb
effective_assets-1.0.0 app/models/effective/attachment.rb