无法运行'耙回形针:刷新:缩略图CLASS = S preE ::图片“在轨US preE控制台应用程序没有得到这样的关键回形针、控制台、缩略图、应用程序

2023-09-11 09:36:40 作者:毁花能手.

我试图 RAILS_ENV =生产运行耙回形针:刷新:缩略图CLASS = S preE ::图片

我在我目前的Rails应用程序目录的远程服务器上,这样我就可以刷新我已经上传在过去的S preE映像。

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.

但每次我运行上面的命令时,我得到当耙中止了没有密钥错误。

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.

为了清楚起见,我有这个问题,因为它是老照片,我已上载与另一S3键在previous测试在同一个Rails应用程序(使用旧的S3键均与老不存在的路径)。我这样做是较早尝试获取S3与我的Rails US preE的应用工作。

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 =生产钢轨ç

然后,我下令所有特殊preE名单:他们本图片:

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

$ Ÿ小号preE :: Image.all(:为了=>'attachment_updated_at')

在'Y'是显示在S preE的信息的一个可爱的小YAML方式:图像,这是一个多一点的人

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

接下来,我看着每个图片的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存储桶是'1078',所以我跑这个最低的ID号:

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

$ 取值preE :: Image.where(ID<,1078).destroy_all

该删除的小号preE ::形象地说,具有1077或更小的ID。

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

最后,我关闭轨道控制台,跑到这是我在我目前的滑轨远程服务器应用程序的目录上。 (在我的情况下是的/ home /部署/应用程序/ potentialapp /电流/)

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 = S preE ::图片

这重新格式化我上传的图片在S preE和一切现在伟大的工作。

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.)