Module: CarrierWave::CouchrestModel

Includes:
Mount
Included in:
CouchRest::Model::Base
Defined in:
lib/carrierwave/orm/couchrest_model.rb

Instance Method Summary collapse

Instance Method Details

#mount_uploader(column, uploader, options = {}, &block) ⇒ Object

See CarrierWave::Mount#mount_uploader for documentation



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/carrierwave/orm/couchrest_model.rb', line 12

def mount_uploader(column, uploader, options={}, &block)
  options[:mount_on] ||= "#{column}_filename"
  property options[:mount_on]

  super

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

  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}!".to_sym
  before_save "write_#{column}_identifier".to_sym
  after_destroy "remove_#{column}!".to_sym
end