All threads / Shrine::Error: storage :cache isn't registered on FileUploader

Ask A Question


You’re not receiving notifications from this thread.

Shrine::Error: storage :cache isn't registered on FileUploader

Ashutosh Mittal asked in Rails

Im using Mongoid 6.0.3, ruby 2.3.1 and rails 5.2

I created a file_uploader class for handling my uploads using shrine.


class FileUploader < Shrine
    Attacher.validate do
        validate_max_size 5.megabytes, message: 'is too large (max is 5 MB)'
        validate_mime_type_inclusion %w(application/pdf image/png application/plain text/plain text/plain application/excel application/x-excel image/jpeg)


require "shrine"
require "shrine/storage/file_system"
Shrine.storages = {
        cache:"public", prefix: "uploads/cache"), # temporary
        store:"public", prefix: "uploads"), # permanent
Shrine.plugin :mongoid
Shrine.plugin :validation_helpers

But i get error when saving data,

In my Model it is called as
field :file_data

Rails is loading FileUploader before shrine initializer,
After adding require_relative './initializers/shrine'

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 53,130+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.