简体   繁体   中英

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

I've written some statements so that it just ignores the call and not give nil errors etc. My question is...

Should I set up my Rails app to store images to AWS S3 when in development and working in local? 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). 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.

This way I can test in development the same conditions then production.

Hope this may help :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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