Browse Source

A small fix

development
Godwin 11 years ago
parent
commit
dd3caa1161
  1. 34
      app/uploaders/avatar_uploader.rb
  2. 34
      app/uploaders/poster_uploader.rb
  3. 1
      config/unicorn.rb
  4. 4
      lib/tasks/regenerate.rake

34
app/uploaders/avatar_uploader.rb

@ -79,22 +79,22 @@ class AvatarUploader < CarrierWave::Uploader::Base
# super(*versions) # super(*versions)
#end #end
def manipulate! # def manipulate!
cache_stored_file! if !cached? # cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path) # image = ::MiniMagick::Image.open(current_path)
#
begin # begin
image.format(@format.to_s.downcase) if @format # image.format(@format.to_s.downcase) if @format
image = yield(image) # image = yield(image)
image.write(current_path) # image.write(current_path)
image.run_command("identify", '"' + current_path + '"') # image.run_command("identify", '"' + current_path + '"')
ensure # ensure
image.destroy! # image.destroy!
end # end
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e # rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en) # default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en)
message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default) # message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default)
raise CarrierWave::ProcessingError, message # raise CarrierWave::ProcessingError, message
end # end
end end

34
app/uploaders/poster_uploader.rb

@ -39,22 +39,22 @@ class PosterUploader < CarrierWave::Uploader::Base
image['width'] > image['height'] image['width'] > image['height']
end end
def manipulate! # def manipulate!
cache_stored_file! if !cached? # cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path) # image = ::MiniMagick::Image.open(current_path)
#
begin # begin
image.format(@format.to_s.downcase) if @format # image.format(@format.to_s.downcase) if @format
image = yield(image) # image = yield(image)
image.write(current_path) # image.write(current_path)
image.run_command("identify", '"' + current_path + '"') # image.run_command("identify", '"' + current_path + '"')
ensure # ensure
image.destroy! # image.destroy!
end # end
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e # rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en) # default = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :locale => :en)
message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default) # message = I18n.translate(:"errors.messages.mini_magick_processing_error", :e => e, :default => default)
raise CarrierWave::ProcessingError, message # raise CarrierWave::ProcessingError, message
end # end
end end

1
config/unicorn.rb

@ -0,0 +1 @@
rails_env = ENV['RAILS_ENV'] || 'production'

4
lib/tasks/regenerate.rake

@ -15,7 +15,7 @@ namespace :regenerate do
end end
task organization_covers: :environment do task organization_covers: :environment do
#Organization.all.each {|m| m.cover.recreate_versions!} Organization.all.each {|m| m.cover.recreate_versions!}
puts Rails.configuration.database_configuration[Rails.env].to_json.to_s #puts Rails.configuration.database_configuration[Rails.env].to_json.to_s
end end
end end

Loading…
Cancel
Save