Module: CarrierWave::Uploader::Rename

Extended by:
ActiveSupport::Concern
Includes:
Callbacks
Included in:
Base
Defined in:
lib/carrierwave/uploader/rename.rb

Instance Method Summary collapse

Methods included from Callbacks

#with_callbacks

Instance Method Details

#rename!Object

Renames the file



38
39
40
41
42
43
44
45
46
# File 'lib/carrierwave/uploader/rename.rb', line 38

def rename!
  return true if !self.rename?

  with_callbacks(:rename) do
    @file = storage.rename!(@original_file)
    @original_file = nil
    @rename = false
  end
end

#rename?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/carrierwave/uploader/rename.rb', line 31

def rename?
  @rename || false
end

#stale_model?Boolean

Override this method in your uploader to check if the model has been updated.

Returns

NilClass, Boolean

true if the model has been changed, false otherwise

Examples

def stale_model?
  model.folder_changed? # because store_dir is based on the folder property of the model
end

Returns:

  • (Boolean)


27
28
29
# File 'lib/carrierwave/uploader/rename.rb', line 27

def stale_model?
   false
end