Kulpreet उर्फ Jungly


Messed about with JCrop, which is an awesome plugin to capture user cropped image uploads.

Was using it as a front end for user upload of images to the excellent rails plugin - paperclip

There were a couple of nastiness that ate into my time.

Paperclip and setting active record attributes

Apparently, it is best to set the crop_* attributes before you set attachment attribute.

I was expecting paperclip to kick in when you save or after validation of the record. However, it happens just as you set the attachment attribute.

Found an explanation on why it happens as a issue on paperclip

So don’t do

User.create(params[:user].permit(:email, :password, :attachment))

Instead do

user = User.create(params[:user].permit(:email, :password))
user.attachment = params[:user][:attachment]

JCrop’s trueSize

Definitely need to use either boxWidth and boxHeight or trueSize.

I used trueSize cause we already set box height and width to meet the design.