本文介绍了无法运行'曲别针:刷新:缩略图CLASS = Spree :: Image'在Rails Spree应用程序控制台中获得No Such Key的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试 RAILS_ENV =生产运行rake回形针:刷新:缩略图CLASS = Spree :: Image

在当前Rails应用目录中的远程服务器上,因此我可以刷新过去上传的狂欢图像.

on my remote server in my current rails app directory, so I can refresh the spree images that I have uploaded in the past.

我正在使用S3,我的存储桶已正确设置,因为我可以在AWS S3存储桶中的各个ID文件夹中看到产品的每个图像.

I am using S3, my bucket is setup correctly as I can see each of my product's images in individual ID folders in my AWS S3 bucket.

但是,每当我运行上述命令时,耙子中止时都会出现"No Such Key"错误.

But each time I run the above command I get a 'No Such Key' Error when the rake is aborted.

此命令在本地运行,并且运行良好.(很明显没有在本地生产RAILS_ENV =)

This command runs locally and works fine. (obviously without the RAILS_ENV=production locally)

推荐答案

好,所以我写了这个问题自己回答.我希望这个问题有意义.

Ok so I wrote this question to answer it myself. I hope the question makes sense.

为了清楚起见,我遇到了这个问题,因为它是我先前在同一Rails应用程序中通过另一个S3 Key上传的旧图像(与旧S3 Key关联的不存在的旧路径).我在尝试使S3与我的Rails Spree应用程序一起使用时做了此操作.

For clarity, I had this issue because it was old images (old non existing paths that were associated with an old S3 Key) that I had uploaded with another S3 Key in previous testing on the same rails app. I did this earlier while trying to get S3 to work with my Rails Spree Application.

我解决此问题的方法是使用以下命令进入远程服务器上的Rails控制台:

What I did to solve this was go into my Rails console on my remote server with this command:

$ RAILS_ENV =生产导轨c

然后我订购了所有Spree:images的列表:

I then ordered the list of all Spree:Images them with this:

$ y Spree :: Image.all(:order =>'attachment_updated_at')

"y"是显示Spree:Image信息的一种不错的方式,更人性化了.

The 'y' is a nice little yaml way of displaying the information of the Spree:Image that's a little more human.

接下来,我查看了每个图像的ID,发现其中有很多ID与我的AWS S3存储桶中的文件夹不匹配.

Next I looked at the ID of each Image and noticed that there was a good amount of them with IDs that did not match folders in my AWS S3 bucket.

在我的案例中,实际上是S3存储桶中的文件夹的最低ID号是"1078",所以我运行了此代码:

In my Case the lowest ID number that was in fact a folder in my S3 bucket was '1078' so I ran this:

$ Spree :: Image.where('id<?',1078).destroy_all

这删除了ID为1077或更小的任何Spree :: Image.

This deleted any Spree::Image that had an ID of 1077 or less.

最后,我关闭了rails控制台,并在我当前的rails应用程序目录中的远程服务器上运行了它.(在我的情况下是/home/deployer/apps/potentialapp/current/)

Finally, I closed rails console and ran this on my remote server inside my current rails app directory. (In my case is was /home/deployer/apps/potentialapp/current/)

$ RAILS_ENV =生产耙子回形针:刷新:缩略图CLASS = Spree :: Image

这使我在Spree上上传的图像重新格式化,现在一切正常.

This reformatted my uploaded images on Spree and everything is now working great.

希望这可以减轻别人的头疼.(噢,当您进行测试并查看图像是否实际上已重新加载时,清空缓存,几乎在昨晚凌晨4点哭了.)

Hope this saves someone a great big headache. (Oh and empty your cache when you go to test and see if the images have in fact reloaded, almost cried at 4 am last night.)

这篇关于无法运行&amp;#39;曲别针:刷新:缩略图CLASS = Spree :: Image&amp;#39;在Rails Spree应用程序控制台中获得No Such Key的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 08:59