Skip to content

Commit

Permalink
Raise early when Active Storage is not setup (Shopify#392)
Browse files Browse the repository at this point in the history
Instead of waiting until a CSV file is uploaded, this raises an
exception early when a CSV Task is defined by calling csv_collection and
Active Storage is not loaded or its tables created.

I reused part of the message that Rails emits when a file is attached
and one of the Active Storage tables does not exist.
  • Loading branch information
etiennebarrie authored Apr 16, 2021
1 parent 86af7fe commit a030de8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/tasks/maintenance_tasks/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def available_tasks
# An input to upload a CSV will be added in the form to start a Run. The
# collection and count method are implemented.
def csv_collection
if !defined?(ActiveStorage) || !ActiveStorage::Attachment.table_exists?
raise NotImplementedError, "Active Storage needs to be installed\n"\
"To resolve this issue run: bin/rails active_storage:install"
end
include(CsvCollection)
end

Expand Down

0 comments on commit a030de8

Please sign in to comment.