NameError: uninitialized constant Plaqueorder::ShrineImageUploader when using Shrine 2.8 on Rails 5.1.4

NameError: uninitialized constant Plaqueorder::ShrineImageUploader when using Shrine 2.8 on Rails 5.1.4

无论我做什么,我都无法让 Shrine 工作,而且我使用的是最简单的设置。

db/schema.rb

create_table "plaqueorders", force: :cascade do |t|
    ...
    t.text "image_data"
    ...

initializers/shrine.rb

require 'shrine'
require 'shrine/storage/file_system'

Shrine.storages = {
cache: Shrine::Storage::FileSystem.new('public', prefix: 'uploads/cache'),
store: Shrine::Storage::FileSystem.new('public', prefix: 'uploads/store'),
}

Shrine.plugin :activerecord
Shrine.plugin :cached_attachment_data # for forms

uploaders/image_uploader.rb

class ShrineImageUploader < Shrine
end

models/plaqueorder.rb

class Plaqueorder < ApplicationRecord
  belongs_to :user
  validates :plaque_type, presence: true
  include ShrineImageUploader[:image]
end

好吧,首先,似乎 image_uploader.rb 定义了 ShrineImageUploader。我认为该文件将被命名为 shrine_image_uploader.rb,或者 class 将被命名为 ImageUploader

否则,您的命名不匹配。