i'm cropping images with paperclip.
i have a custom module which works great on my local machine (copied from railscast 182).
//file: lib/paperclip_processors/cropper.rb
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
on heroku i get the following error:
NoMethodError (private method `sub' called for ["-resize", "220x", "-crop", "220x220+0+18", "+repage"]:Array):
lib/paperclip_processors/cropper.rb:12:in `transformation_command'
paperclip (2.3.3) lib/paperclip/thumbnail.rb:55:in `make'
paperclip (2.3.3) lib/paperclip/processor.rb:33:in `make'
paperclip (2.3.3) lib/paperclip/attachment.rb:295:in `post_process_styles'
paperclip (2.3.3) lib/paperclip/attachment.rb:294:in `each'
paperclip (2.3.3) lib/paperclip/attachment.rb:294:in `inject'
paperclip (2.3.3) lib/paperclip/attachment.rb:294:in `post_process_styles'
paperclip (2.3.3) lib/paperclip/attachment.rb:291:in `each'
paperclip (2.3.3) lib/paperclip/attachment.rb:291:in `post_process_styles'
paperclip (2.3.3) lib/paperclip/attachment.rb:285:in `post_process'
paperclip (2.3.3) lib/paperclip/callback_compatability.rb:23:in `call'
paperclip (2.3.3) lib/paperclip/callback_compatability.rb:23:in `run_paperclip_callbacks'
paperclip (2.3.3) lib/paperclip/attachment.rb:284:in `post_process'
paperclip (2.3.3) lib/paperclip/callback_compatability.rb:23:in `call'
paperclip (2.3.3) lib/paperclip/callback_compatability.rb:23:in `run_paperclip_callbacks'
paperclip (2.3.3) lib/paperclip/attachment.rb:283:in `post_process'
paperclip (2.3.3) lib/paperclip/attachment.rb:214:in `reprocess!'
app/models/user.rb:339:in `reprocess_avatar'
app/controllers/user_controller.rb:57:in `update_avatar'
haml (2.2.3) rails/./lib/sass/plugin/rails.rb:19:in `process'
/home/heroku_rack/lib/static_assets.rb:9:in `call'
/home/heroku_rack/lib/last_access.rb:25:in `call'
/home/heroku_rack/lib/date_header.rb:14:in `call'
thin (1.0.1) lib/thin/connection.rb:80:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:78:in `catch'
thin (1.0.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:57:in `process'
thin (1.0.1) lib/thin/connection.rb:42:in `receive_data'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run_machine'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run'
thin (1.0.1) lib/thin/backends/base.rb:57:in `start'
thin (1.0.1) lib/thin/server.rb:150:in `start'
thin (1.0.1) lib/thin/controllers/controller.rb:80:in `start'
thin (1.0.1) lib/thin/runner.rb:173:in `send'
thin (1.0.1) lib/thin/runner.rb:173:in `run_command'
thin (1.0.1) lib/thin/runner.rb:139:in `run!'
thin (1.0.1) bin/thin:6
/usr/local/bin/thin:20:in `load'
/usr/local/bin/thin:20