Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist active storage uploads between deployments #475

Merged
merged 2 commits into from
Sep 15, 2018

Conversation

cattywampus
Copy link
Collaborator

Resolves #1

Description

With the introduction of Active Storage in Rails 5, each new deployment was causing the images that have been uploaded to be lost. This fix ensures that uploads managed by Active Storage are persisted and carried along between deployments so logos don't need to be re-uploaded.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

To test this, deploy a version of the site without using the fix (i.e., without the updated linked_dirs setting in capistrano). This is actually easy to do since capistrano cues off of the code in your working directory rather than in the branch you are trying to deploy.

On the remote server, you'll need to delete the ~/apps/diaper_base/shared/storage folder, since it's existence in combination with the code in the branch fixes the issue.

 # This is so your local capistrano config has the fix
git checkout --track origin/active_storage_prawn  

# this will break the logos by creating a new release, leaving the previously updated
# logos in the previous release directory. But this will also create a new storage folder
# in shared/ and symlink it to the new deployment. Since the is a fresh setup, the logos 
# will be broken.
cap production deploy BRANCH=active_storage_prawn

# go to the test site and re-upload a logo. 

# Deploy a 2nd time and the logo should persist
cap production deploy BRANCH=active_storage_prawn

seanmarcia and others added 2 commits September 15, 2018 15:07
If the organization doesn't upload a logo, we should at least show some
picture in it's place. This uses the stock diaperbase logo, which will
show up on the org's homepage and pdf reports.
Active Storage is configured to store uploads under the `storage/` path
in `Rails.root`. This folder needs to be symlinked from the capistrano
`shared/` path so that way the same uploads can persist between
deployments.
@cattywampus cattywampus changed the title Persist active storage between deployments Persist active storage uploads between deployments Sep 15, 2018
@armahillo armahillo added this to the National Diaper Bank Demo milestone Sep 15, 2018
@armahillo armahillo merged commit ec1beef into master Sep 15, 2018
@armahillo armahillo deleted the active_storage_prawn branch September 15, 2018 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants