简体   繁体   English

带有AWS的Rails 5.2 Active Storage(本地开发)

[英]Rails 5.2 Active Storage with AWS (Local Development)

I've set up AWS S3 to store my images on Rails 5.2 with active storage when in production mode. 我已将AWS S3设置为在生产模式下将图像存储在具有活动存储的Rails 5.2上。 This is great however I've noticed if I copy down the database from Heroku to my local machine so that I can work on the current platform state I get missing images due to the virtual blob storage in active storage. 很好,但是我注意到,如果我将数据库从Heroku复制到本地计算机,以便可以在当前平台状态下工作,则由于活动存储中的虚拟Blob存储而丢失了映像。

I've written some statements so that it just ignores the call and not give nil errors etc. My question is... 我已经写了一些语句,以便它只忽略调用而不会给出nil错误等。我的问题是...

Should I set up my Rails app to store images to AWS S3 when in development and working in local? 在开发和在本地工作时,是否应该设置Rails应用程序将图像存储到AWS S3? This doesn't seem right however I am unsure how I can just copy down the production database into my local machine and the images will appear too (active storage blob url will be correct). 这似乎不对,但是我不确定如何将生产数据库复制到本地计算机中,并且图像也将出现(活动存储Blob URL正确)。 I'm guessing it's a config issue on the local side coupled up with active storage..... (Head scratching). 我猜想这是本地方面的配置问题,再加上活动存储.....(头部抓挠)。

Has anyone else come across this? 还有其他人遇到吗? Thank you. 谢谢。

This is the way I've been using Active Storage: I have two databases (one local for development and the other on Heroku for production) and two cloud storage buckets (dev/prod), so when I'm developing I'll be using the same cloud storage as in production, but each database is associated with each own bucket. 这就是我一直使用Active Storage的方式:我有两个数据库(一个用于开发,而另一个在Heroku上用于生产)和两个云存储桶(dev / prod),所以在开发时,我会使用与生产中相同的云存储,但是每个数据库都与每个自己的存储桶相关联。

This way I can test in development the same conditions then production. 这样,我可以在开发中测试与生产相同的条件。

Hope this may help :-) 希望这会有所帮助:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM