I try to add Shrine gem to an existing project that uses Paperclip. I added a Shrine image to a new model (just for a check). So I created model Country with this db table:
create_table "countries", force: :cascade do |t|
t.string "name"
t.text "image_data"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
and this model:
class Country < ApplicationRecord
include ImageUploader::Attachment(:image)
validates :name, length: { in: 2..180 }, presence: true
end
After that I tried to get image from country and received this (image_data works, though):
I thought that maybe it's because image is empty, but in another app with shrine everything works correctly
Does anyone know how to fix this?
It seems that somehow shrine uploader was loaded before shrine.rb file so that I couldn't use any shrine methods. Similar issue can be found here: https://github.com/shrinerb/shrine/issues/155
Adding require_relative '../../config/initializers/shrine'
to the uploader resolved the issue