値をモデルインスタンスに保存できます
次に、モデル属性で取得するためのプロセスメソッドで
# model class
# define attr_accessor coords
class User < ActiveRecord::Base
attr_accessor :coords
mount_uploader :icon, AvatarUploader
end
# controller
# pass the params to @user.coords
def crop_icon
@user.coords = params[:coords]
@user.icon = params[:icon]
@user.save
end
# Uploader
# the model in the function is same as @user in controll,
# and can be invoked inside of process method
def crop_area
manipulate! do |img|
unless model.coords.nil?
coords = JSON.parse(model.coords)
img.crop("#{coords['w']}x#{coords['h']}+#{coords['x']}+#{coords['y']}")
end
img = yield(img) if block_given?
img
end
end