Module: CarrierWave::Mongoid
- Includes:
- Mount
- Defined in:
- lib/carrierwave/orm/mongoid.rb
Instance Method Summary collapse
-
#mount_uploader(column, uploader, options = {}, &block) ⇒ Object
See CarrierWave::Mount#mount_uploader for documentation.
Methods included from Mount
#uploader_option, #uploader_options, #uploaders
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/mongoid.rb', line 12 def mount_uploader(column, uploader, ={}, &block) [:mount_on] ||= "#{column}_filename" field [: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 |