1

I cannot get Shrine to work no matter what I do and I am using the simplest of setups to start with.

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
4

1 回答 1

2

Welp,首先,它似乎image_uploader.rb定义了ShrineImageUploader. 我认为文件将被命名shrine_image_uploader.rb或类将被命名ImageUploader

否则,您的命名不匹配。

于 2017-10-17T19:19:26.563 回答