Having some trouble trying to get this to work in Rails 4 - http://railscasts.com/episodes/182-cropping-images?view=comments
As per one of the questions in the comments: using the after_update callback to update the images, it ran into an infinite loop
Apparently the fix is to put @user.avatar.reprocess! directly in the controller instead. However I am not sure where exactly in the controller this should go. And if I'm putting this in the right place is it going to work with rails 4?
I have tried the following with no luck:
def create
@user = User.new(user_params)
if @user.save
if user_params[:avatar].blank?
@user.avatar.reprocess!
flash[:notice] = "Successfully created user."
redirect_to @user
else
render :action => "crop"
end
else
render 'new'
end
end
def update
@user = User.find(params[:id])
if @user.update_attributes(user_params)
if user_params[:avatar].blank?
@user.avatar.reprocess!
flash[:notice] = "Successfully updated user."
redirect_to @user
else
render :action => "crop"
end
else
render :action => 'edit'
end
end