Sha256: ff5079d43c02b58fdaef1551f5bd6fcb72190f27bfcef549307de5f2ebea586e

Contents?: true

Size: 941 Bytes

Versions: 6

Compression:

Stored size: 941 Bytes

Contents

# encoding: utf-8

require 'active_record'
require 'carrierwave/validations/active_model'

module CarrierWave
  module ActiveRecord

    include CarrierWave::Mount

    ##
    # See +CarrierWave::Mount#mount_uploader+ for documentation
    #
    def mount_uploader(column, uploader, options={}, &block)
      super

      alias_method :read_uploader, :read_attribute
      alias_method :write_uploader, :write_attribute
      public :read_uploader
      public :write_uploader

      include CarrierWave::Validations::ActiveModel

      validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
      validates_processing_of column if uploader_option(column.to_sym, :validate_processing)

      after_save "store_#{column}!"
      before_save "write_#{column}_identifier"
      after_destroy "remove_#{column}!"

    end

  end # ActiveRecord
end # CarrierWave

ActiveRecord::Base.extend CarrierWave::ActiveRecord

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
locomotive_carrierwave-0.5.0.1.beta3 lib/carrierwave/orm/activerecord.rb
carrierwave-0.5.2 lib/carrierwave/orm/activerecord.rb
carrierwave-0.5.1 lib/carrierwave/orm/activerecord.rb
locomotive_carrierwave-0.5.0.1.beta2 lib/carrierwave/orm/activerecord.rb
locomotive_carrierwave-0.5.0.1.beta1 lib/carrierwave/orm/activerecord.rb
locomotive_carrierwave-0.5.0.1 lib/carrierwave/orm/activerecord.rb