Module: CarrierWave::ActiveRecord

Includes:
Mount
Defined in:
lib/carrierwave/orm/activerecord.rb

Instance Method Summary collapse

Methods included from Mount

#uploader_option, #uploader_options, #uploaders

Instance Method Details

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

See CarrierWave::Mount#mount_uploader for documentation



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/carrierwave/orm/activerecord.rb', line 12

def mount_uploader(column, uploader=nil, options={}, &block)
  super

  mod = Module.new
  prepend mod
  mod.class_eval <<-RUBY, __FILE__, __LINE__+1
    def remote_#{column}_url=(url)
      column = _mounter(:#{column}).serialization_column
      __send__(:"\#{column}_will_change!")
      super
    end
  RUBY
end

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

See CarrierWave::Mount#mount_uploaders for documentation



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/carrierwave/orm/activerecord.rb', line 29

def mount_uploaders(column, uploader=nil, options={}, &block)
  super

  mod = Module.new
  prepend mod
  mod.class_eval <<-RUBY, __FILE__, __LINE__+1
    def remote_#{column}_urls=(url)
      column = _mounter(:#{column}).serialization_column
      __send__(:"\#{column}_will_change!")
      super
    end
  RUBY
end