So I've been trying to fix this for a while now and I've had no luck in doing so. I have a model Posts that has_rich_text: body
class Post < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :slugged
has_rich_text :body
has_rich_text :health_check
has_one_attached :cover_photo
has_many :post_tags, dependent: :destroy
has_many :tags, through: :post_tags
after_commit :add_default_cover, on: [:create, :update]
def add_default_cover
unless cover_photo.attached?
self.cover_photo.attach(io: File.open(Rails.root.join("app", "assets", "images", "default.png")), filename: 'default.png' , content_type: "image/png")
end
end
end
It works perfectly when I attach photos, but when ever I attach a gif it gets uploaded correctly into the edit/new screen and I can see the animation of the gif in the rich text editor. But as soon as I submit the edit/new form then a new variant is created as an image and that's what is being used when showing the post. When I check my storage system I find both the image and the gif versions.
Does anyone know why this is happening on submitting the form? I would want to upload a gif and display it without active stroage or action text changing it.