aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorAlex Gomez <alex.gomez@shopify.com>2019-06-06 10:29:45 -0400
committerGitHub <noreply@github.com>2019-06-06 10:29:45 -0400
commita057569685471fc668b269bfa6f4c282b09e399e (patch)
tree7350c989d91d868c202aee3b8f08294f4a817d78 /guides
parent480d9f2d2431e6a11c89edb45123181f9b6db958 (diff)
downloadrails-a057569685471fc668b269bfa6f4c282b09e399e.tar.gz
rails-a057569685471fc668b269bfa6f4c282b09e399e.tar.bz2
rails-a057569685471fc668b269bfa6f4c282b09e399e.zip
Include warning in docs about polymorphism in underlying tables
We had a bug whereby we changed the namespace on a model using ActiveStorage, which resulted in broken download links. The reason this happened is because the `active_storage_attachments` table is a polymorphic join table that records the model's class name at the time of record creation, and uses this `record_type` in queries. Since the model namespace changed, the queries did not return the blob as expected. Discussed with @rafaelfranca, who suggested adding a warning about this in the docs.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_storage_overview.md2
1 files changed, 2 insertions, 0 deletions
diff --git a/guides/source/active_storage_overview.md b/guides/source/active_storage_overview.md
index 2986850cef..932a5dc2e9 100644
--- a/guides/source/active_storage_overview.md
+++ b/guides/source/active_storage_overview.md
@@ -41,6 +41,8 @@ application (or upgrading your application to Rails 5.2), run
`rails active_storage:install` to generate a migration that creates these
tables. Use `rails db:migrate` to run the migration.
+WARNING: `active_storage_attachments` is a polymorphic join table that stores your model's class name. If your model's class name changes, you will need to run a migration on this table to update the underlying `record_type` to your model's new class name.
+
Declare Active Storage services in `config/storage.yml`. For each service your
application uses, provide a name and the requisite configuration. The example
below declares three services named `local`, `test`, and `amazon`: