From de217b74b7b16fe3ba6713bfa5650d94b96b30a1 Mon Sep 17 00:00:00 2001 From: did Date: Sat, 11 Jun 2011 01:18:34 +0200 Subject: [PATCH] use default rails logger during the first template import + remove some carrierwave method patches now useless with the new version of the gem --- .../extensions/site/first_installation.rb | 2 +- lib/locomotive/carrierwave/patches.rb | 28 +++---------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/app/models/extensions/site/first_installation.rb b/app/models/extensions/site/first_installation.rb index f38d92ac..4e9473c3 100644 --- a/app/models/extensions/site/first_installation.rb +++ b/app/models/extensions/site/first_installation.rb @@ -27,7 +27,7 @@ module Extensions begin Locomotive::Import::Job.run!(source, site, { :samples => true }) rescue Exception => e - logger.error "The import of the site template failed because of #{e.message}" + Rails.logger.error "The import of the site template failed because of #{e.message}" end end diff --git a/lib/locomotive/carrierwave/patches.rb b/lib/locomotive/carrierwave/patches.rb index c0f6bf15..52b941db 100644 --- a/lib/locomotive/carrierwave/patches.rb +++ b/lib/locomotive/carrierwave/patches.rb @@ -4,33 +4,13 @@ module CarrierWave class SanitizedFile - def original_filename=(filename) - @original_filename = filename - end - - def content_type=(content_type) - @content_type = content_type - end - - # http://github.com/jnicklas/carrierwave/issuesearch?state=closed&q=content+type#issue/48 - def copy_to_with_content_type(new_path, permissions=nil) - new_file = self.copy_to_without_content_type(new_path, permissions) - new_file.content_type = self.content_type - new_file - end - - alias_method_chain :copy_to, :content_type - # FIXME (Did) CarrierWave speaks mime type now - def content_type - return @content_type if @content_type - if @file.respond_to?(:content_type) and @file.content_type - @file.content_type.chomp - else - File.mime_type?(@file) if @file.is_a?(String) - end + def content_type_with_file_mime_type + content_type_without_file_mime_type || File.mime_type?(original_filename) end + alias_method_chain :content_type, :file_mime_type + end module Uploader