Get paperclip to crop the image without validating
- by Micke
Hello fellow stackoverflow members.
I have been following this guide to enable users to have their own avatar.
But i have bumped in to a litle problem.
When the user is cropping the image the model tries to validate all my validations.
My user model looks like this:
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :small => "100x100>", :large => "500x500>" }, :processors => [:cropper]
attr_accessor :password, :crop_x, :crop_y, :crop_w, :crop_h
attr_accessible :crop_x, :crop_y, :crop_w, :crop_h
validates_confirmation_of :password
validates_presence_of :password
And when the user runs the crop updating script the user model tries to validate the password. But because i have no password field on the cropping page it can't validate it.
Here is the updating of the crop:
@user = User.find(current_user.id)
if @user.update_attributes(params[:user])
flash[:notice] = "Successfully updated user."
end
How can i bypass this in a easy and clean way?