#実現したいこと
formから送られてきた画像を、MiniMagickの機能を使ってトリミングしたい。
#該当のソースコード
Ruby
1Upload image crop with Ruby and Rails, CarrierWave and Cropper.js 2 3class PictureUploader < CarrierWave::Uploader::Base 4 include CarrierWave::MiniMagick 5 process :crop 6 process resize_to_fill: [400, 400] 7 8 private 9 10 def crop 11 manipulate! do |img| 12 crop_x = model.image_x.to_i 13 crop_y = model.image_y.to_i 14 crop_w = model.image_w.to_i 15 crop_h = model.image_h.to_i 16 17 img.crop "#{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}" 18 img = yield(img) if block_given? 19 img 20 end 21 end 22
#起こっている問題
Ruby
1img.crop "#{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"
の行で、
「wrong number of arguments (given 1, expected 0)」
というエラーが出てしまいます。
あなたの回答
tips
プレビュー