Paperclip Ralis 4 Reprocess attr_accessor
My rails 4 application is having some issues with the paperclip reprocess
method. I have a custom Cropper module:
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
crop_command + super.sub(/ -crop \S+/, '')
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
ratio = target.avatar_geometry(:original).width /
target.avatar_geometry(:large).width
["-crop",
"#{(target.crop_w.to_i*ratio).round}x#{(target.crop_h.to_i*ratio).round}+#{(target.crop_x.to_i*ratio).round}+#{(target.crop_y.to_i*ratio).round}"]
end
end
end
end
And I have a few attr_accessors for the crop_x, crop_y, crop_w, crop_h.
I'm running into an issue with having crop_x, y, w, and h available when
it hits the cropper class. Those elements are always nil even if in the
controler (during the update method) that these aren't nil.
I believe this has to do with them be attr_accessors, so I'm looking for
some advice as to how to handle this.
No comments:
Post a Comment