In the Readme it states
"The model variable points to the instance object the uploader is attached to." But I have found this not to be true when using recreate_versions!.
I have some attr_accessor's set up on my model and those are not available to me in the uploader class when recerate_versions! is called, yet they are available in the class when I call avatar.model.attr_accessor_name
Below is my code. avatar.model in the user class gives correct results. But in the AvatarUploader class itself model returns nil for the accessors when they are set for what should be that instance. This makes me believe that recreate_versions! isn't passing the correct instance.
class User < ActiveRecord::Base
self.avatar.model.crop_x.present? ##=> correctly works
class AvatarUploader < CarrierWave::Uploader::Base
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
version :small do
process :resize_to_fill => [32, 32]
##This code here is never run, model.crop_x.present? is always nil, but should be true in some cases. why?
manipulate! do |img|
x = model.crop_x
y = model.crop_y
w = model.crop_w
h = model.crop_h
By the way I got this technique from railscast-182 if you want code to test, try the sample app he provides there, it is currently broken because of this bug.
I'm unable to reproduce this issue. Feel free to post a sample app demonstrating the issue and we can take a look.