RailsCasts Pro episodes are now free!

Learn more or hide this

fona's Profile

GitHub User: fona

Comments by

Avatar

I encountered a few issues using paperclip 3.2.0.

When using the after_update callback to update the images, it ran into an infinite loop, since paperclip updates the avatar_updated_at column on the model after it completes the crop, so the model gets updated again and re-kicks off the callback.

To resolve this I called @user.avatar.reprocess! directly in the controller if cropping.

Reference Thread: https://github.com/thoughtbot/paperclip/issues/866

I also had some issues with the Cropper Processor in this cast, so I used the code from here: http://viget.com/extend/manual-cropping-with-paperclip

Also, I created a crop_box style, which I explicitly exclude from my cropping processor, so that I can display an unaltered 250x250 image so the user can continually go back and edit their "original" image, and the cropping only applies to thumb nails and medium images. I simply did that by wrapping the logic in transformation_command with:

def transformation_command
if target.cropping? && ![CROP_BOX_PAPERCLIP_STYLE].include?(options[:geometry])
....
else
super
end
end

I declared CROP_BOX_PAPERCLIP_STYLE in environment.rb so that it is available across my application.

It does force me to give crop_box a very unique size so it wont bump into other styles I have!

Good luck and thanks for the cast!