问题
Greetings wise people,
I am trying to use MiniMagick with CarrierWave in Rails 3 to resize and store an image according to the instructions here: http://carrierwave.rubyforge.org/rdoc/classes/CarrierWave/MiniMagick.html
I can upload images with no processing. The image is uploaded and I can see it in the directory and the application. But when I try to perform processing on the image, the block inside manipulate!
method is never being called. Do you know how I can solve this?
I have the following uploader that works:
class MyContentImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
end
With this code, I am able to upload images using my form and view them on the result page. Everything is peachy.
I added a simple resize to the uploader like this:
class MyContentImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process resize_to_fit: [200,200]
end
After adding the process call, the image does not upload, but I also never see an error. I tried to add a custom method to the uploader and saw the same result:
class MyContentImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def do_stuff:
manipulate! do |img|
img = img.resize_to_fit(200,200)
end
end
end
Nothing happens. The image doesn't update on the server, but I never see an error. I placed some raise
calls into the do_stuff
method to see how far the call was executing. It turns out the do_stuff
method is being called, but the block inside manipulate!
is not. How could this be happening? How would you troubleshoot this problem?
Additional info: I have inside config/initializers/carrierwave.rb the following code, so I believe processing is enabled:
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = true
end
I am using:
- Rails 3.2.12
- CarrierWave 0.8.0
- MiniMagick 3.5.0
来源:https://stackoverflow.com/questions/15503652/carrierwave-rmagick-how-do-i-cause-manipulate-to-be-called