I am trying to copy avatars from another model to my User model, but I get an AWS::S3::Errors::NoSuchKey when I try to do this.
Here is the code that throws the error:
old_avatar = OldAvatar.find(1) user = User.find(old_avatar.user_id) user.avatar = old_avatar.avatar user.save
The string user.avatar = old_avatar.avatar is what throws it away.
Here is my OldAvatar model ...
has_attached_file :avatar, :styles => { :t => '20x20#', :s => '40x40#', :m => '50x50#', :b => '80x80#', :f => '100x100#' }, :storage => :s3, :s3_credentials => { :access_key_id => APP_CONFIG['s3_access_key_id'], :secret_access_key => APP_CONFIG['s3_secret_access_key'] }, :path => ":attachment/:id/:basename:normalized_style.:extension", :url => "/:attachment/:id/:basename:normalized_style.:extension", :bucket => "old_bucket"
And here is my User model ...
has_attached_file :avatar, :styles => { :t => '20x20#', :s => '40x40#', :m => '50x50#', :b => '80x80#', :f => '100x100#' }, :storage => :s3, :s3_credentials => { :access_key_id => APP_CONFIG['s3_access_key_id'], :secret_access_key => APP_CONFIG['s3_secret_access_key'] }, :bucket => "new_bucket", :path => ":attachment/:id_partition/:basename_:style.:extension", :url => "/:attachment/:id_partition/:basename_:style.:extension"
Notice, I am copying between two different buckets (as indicated in another model model code), so maybe this has something to do with this?