lundi 16 décembre 2019

MimeMagic::Encoding error when recreating versions in carrierwave

I am having difficulties recreating versions in carrierwave. The initial upload goes well only the recreate versions throws an error.

I have

mount_uploader :file_name, DiapoUploader

def reprocess
  begin
    self.file_name.cache_stored_file!
    self.file_name.retrieve_from_cache!(self.file_name.cache_name)
    self.file_name.recreate_versions!
    self.save!
  rescue => e
    STDERR.puts  "ERROR: Diapo: #{id} -> #{e.to_s}"
  end
end

in my model Diapo.rb and when I call

Diapo.all.each do |diapo|
  diapo.reprocess
end

in a rake task I get the following error:

$ rake carrierwave:reprocess_diapo          
ERROR: Diapo: 1 -> uninitialized constant MimeMagic::Encoding

$ rake carrierwave:reprocess_diapo --trace
** Invoke carrierwave:reprocess_diapo (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute carrierwave:reprocess_diapo
rake aborted!
NameError: uninitialized constant MimeMagic::Encoding
/Users/myaccount/.rvm/gems/ruby-stuff/gems/mimemagic-0.3.3/lib/mimemagic.rb:116:in `magic_match'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/mimemagic-0.3.3/lib/mimemagic.rb:81:in `by_magic'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/carrierwave-0.11.1/lib/carrierwave/sanitized_file.rb:318:in `mime_magic_content_type'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/carrierwave-0.11.1/lib/carrierwave/sanitized_file.rb:250:in `content_type'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/carrierwave-0.11.1/lib/carrierwave/uploader/cache.rb:96:in `sanitized_file'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/carrierwave-0.11.1/lib/carrierwave/uploader/cache.rb:128:in `cache!'
/Users/myaccount/.rvm/gems/ruby-stuff/gems/carrierwave-0.11.1/lib/carrierwave/uploader/versions.rb:226:in `recreate_versions!'
/Users/myaccount/Development/REPRO/projecty/lib/tasks/carrierwave.rake:11
/Users/myaccount/Development/REPRO/project/lib/tasks/carrierwave.rake:9:in `each'
/Users/myaccount/Development/REPRO/project/lib/tasks/carrierwave.rake:9
.
.
.
Tasks: TOP => carrierwave:reprocess_diapo

What am I missing?

Aucun commentaire:

Enregistrer un commentaire