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)
#end
def manipulate!
cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path)
begin
image.format(@format.to_s.downcase) if @format
image = yield(image)
image.write(current_path)
image.run_command("identify", '"' + current_path + '"')
ensure
image.destroy!
end
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
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)
raise CarrierWave::ProcessingError, message
end
# def manipulate!
# cache_stored_file! if !cached?
# image = ::MiniMagick::Image.open(current_path)
#
# begin
# image.format(@format.to_s.downcase) if @format
# image = yield(image)
# image.write(current_path)
# image.run_command("identify", '"' + current_path + '"')
# ensure
# image.destroy!
# end
# rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
# 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)
# raise CarrierWave::ProcessingError, message
# end
end

34
app/uploaders/poster_uploader.rb

@ -39,22 +39,22 @@ class PosterUploader < CarrierWave::Uploader::Base
image['width'] > image['height']
end
def manipulate!
cache_stored_file! if !cached?
image = ::MiniMagick::Image.open(current_path)
begin
image.format(@format.to_s.downcase) if @format
image = yield(image)
image.write(current_path)
image.run_command("identify", '"' + current_path + '"')
ensure
image.destroy!
end
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
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)
raise CarrierWave::ProcessingError, message
end
# def manipulate!
# cache_stored_file! if !cached?
# image = ::MiniMagick::Image.open(current_path)
#
# begin
# image.format(@format.to_s.downcase) if @format
# image = yield(image)
# image.write(current_path)
# image.run_command("identify", '"' + current_path + '"')
# ensure
# image.destroy!
# end
# rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
# 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)
# raise CarrierWave::ProcessingError, message
# 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
task organization_covers: :environment do
#Organization.all.each {|m| m.cover.recreate_versions!}
puts Rails.configuration.database_configuration[Rails.env].to_json.to_s
Organization.all.each {|m| m.cover.recreate_versions!}
#puts Rails.configuration.database_configuration[Rails.env].to_json.to_s
end
end

Loading…
Cancel
Save