这是抛出错误的代码:
old_avatar = oldAvatar.find(1)user = User.find(old_avatar.user_ID)user.avatar = old_avatar.avataruser.save
user.avatar = old_avatar.avatar行是抛出它的原因.
这是我的oldAvatAR模型……
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"
这是我的用户模型……
has_attached_file :avatar,:styles => { :t => '20x20#',:f => '100x100#' },: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"
请注意,我正在两个不同的桶之间复制(如不同的型号代码中所述),所以这可能与它有关?
解决方法 事实证明我的某些早期图像有一些不一致的路径,因此它们与我为Paperclip设置的路径不匹配(因此生成了错误的图像URL).所以,问题解决了.
总结以上是内存溢出为你收集整理的ruby-on-rails – 复制时Paperclip AWS :: S3 :: Errors :: NoSuchKey错误全部内容,希望文章能够帮你解决ruby-on-rails – 复制时Paperclip AWS :: S3 :: Errors :: NoSuchKey错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)