I am following Episode: 182-cropping-images for cropping user profile image.
AR relation is User has one Profile Image: In User model:
has_one :profile_image, :as => :imageable, :class_name => 'ProfileImage', :dependent => :destroy
In ProfileImage Model:
class ProfileImage < Image
has_attached_file :data, :styles => {
:large => "160x160>",
:grid => "114x114>",
:medium => "80x80>",
:list => "60x60>",
:square => "32x32!",
:tiny => "20x20!",
:icon => "16x16!"
}, :processors => [:cropper]
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
def cropping?
!crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
end
def avatar_geometry(style = :original)
@geometry ||= {}
@geometry[style] ||= Paperclip::Geometry.from_file(data.path(style))
end
In lib/paperclip_processors/cropper.rb lib:
module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
["-crop", "#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}"]
end
end
end
end
and all other things like Episode: 182-cropping-images with solution Now, I am getting error:
NoMethodError Exception: super: no superclass method 'transformation_command' for Paperclip::Cropper
in line:
crop_command + super.join(' ').sub(/ -crop \S+/, '').split(' ')
If I remove, + super.join(' ').sub(/ -crop \S+/, '').split(' ')
It crops all images style into same height width. Please guide.