I've been struggling to figure out why I'm receiving this error on Heroku.
Shrine::Error (storage :cache isn't registered on PdfUploader)
initializer.rb
require "shrine"
require "shrine/storage/s3"
s3_options = {
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
region: ENV.fetch('AWS_REGION'),
bucket: ENV.fetch('AWS_BUCKET')
}
Shrine.storages = {
cache: Shrine::Storage::S3.new(prefix: "cache", upload_options: {acl: "public-read"}, **s3_options),
store: Shrine::Storage::S3.new(prefix: "store", upload_options: {acl: "public-read"}, **s3_options)
}
Shrine.plugin :activerecord
Shrine.plugin :direct_upload, presign: true
pdf_uploader.rb
class PdfUploader < Shrine
plugin :determine_mime_type
plugin :validation_helpers
Attacher.validate do
validate_mime_type_inclusion %w(image/jpeg image/png image/gif application/pdf), message: 'must be JPEG, PNG, GIF, or PDF'
end
end
I'm able to upload to the cache folder in my AWS bucket directly from the DOM with jquery-file-upload and the route I've established for getting the presign URL:
mount PdfUploader::UploadEndpoint => '/pdfs/upload'
However, when trying to submit my form and create my object in the db, I get the following error:
Shrine::Error (storage :cache isn't registered on PdfUploader)
Any thoughts or suggestions would be greatly appreciated. Thanks!
PS - for what it's worth - everything works on my local ... this issue is just on Heroku