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.6.2 app/models/effective/attachment.rb
effective_assets-1.6.1 app/models/effective/attachment.rb
effective_assets-1.6.0 app/models/effective/attachment.rb
effective_assets-1.5.9 app/models/effective/attachment.rb
effective_assets-1.5.8 app/models/effective/attachment.rb
effective_assets-1.5.7 app/models/effective/attachment.rb
effective_assets-1.5.6 app/models/effective/attachment.rb
effective_assets-1.5.5 app/models/effective/attachment.rb
effective_assets-1.5.4 app/models/effective/attachment.rb
effective_assets-1.5.3 app/models/effective/attachment.rb
effective_assets-1.5.2 app/models/effective/attachment.rb
effective_assets-1.5.1 app/models/effective/attachment.rb
effective_assets-1.5.0 app/models/effective/attachment.rb
effective_assets-1.4.9 app/models/effective/attachment.rb
effective_assets-1.4.8 app/models/effective/attachment.rb
effective_assets-1.4.7 app/models/effective/attachment.rb
effective_assets-1.4.6 app/models/effective/attachment.rb
effective_assets-1.4.5 app/models/effective/attachment.rb
effective_assets-1.4.4 app/models/effective/attachment.rb
effective_assets-1.4.3 app/models/effective/attachment.rb