我必须包含 paperclip_processors 目录我得到cropper processor not found 错误。我跟着 railscast 做的完全一样
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?
" -crop '#{target.crop_w.to_i}x#{target.crop_h.to_i}+#{target.crop_x.to_i}+#{target.crop_y.to_i}'"
end
end
end
end
在应用程序.rb
config.autoload_paths += %W(#{Rails.root}/lib)
config.autoload_paths += %W(#{Rails.root}/lib/paperclip_processors)
和用户.rb
has_attached_file :profile_picture, {
styles: {
original: "1400>",
medium: "400>",
thumb: "150>"
},
:processors => [:cropper],
storage: :s3,
s3_credentials: S3_CREDENTIALS,
}