Started up a brand new Rails 6 app with Shrine, everything is fresh out of the box following along with the getting started guide. Got the file uploaded successfully but on the show page the img tag is just a broken image icon but if I open it in a new tab, it shows. No errors showing in the console.
/config/initializers/shrine.rb
require "shrine"
require "shrine/storage/file_system"
Shrine.storages = {
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"), # temporary
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads") # permanent
}
Shrine.plugin :activerecord # loads Active Record integration
Shrine.plugin :cached_attachment_data # enables retaining cached file across form redisplays
Shrine.plugin :restore_cached_data # extracts metadata for assigned cached files
app/uploaders/image_uploader.rb
class ImageUploader < Shrine
# plugins and uploading logic
end
app/models/content.rb
class Content < ApplicationRecord
include ImageUploader::Attachment(:image) # adds an `image` virtual attribute
end
views/contents/show.html.erb
<p>
<strong>Image:</strong>
<%= image_tag @content.image_url %>
</p>
page source
<img src="/uploads/efe42a8e0d19d3ffcabd26bcddd71473.mp4">
Figured it out. I pulled the "gif" I was testing with from Imgur, which is actually an mp4 and thus not going to show in an "image_tag". Changed it to "video_tag" and it's working.