class ActionText::Attachment
def to_plain_text
attachment = ActionText::Attachment.from_attachable(attachable)
attachable = Person.create! name: "Javan"
end
end
"[#{name}]"
def attachable_plain_text_representation
include ActionText::Attachable
class Person < ApplicationRecord
`attachable_plain_text_representation` method:
The presentation can be overridden by implementing the
attachment.to_plain_text # => "[Vroom vroom]"
attachment = ActionText::Attachment.from_attachable(attachable, caption: "Vroom vroom")
Use the `caption` when set:
attachment.to_plain_text # => "[racecar.jpg]"
attachment = ActionText::Attachment.from_attachable(attachable)
attachable = ActiveStorage::Blob.find_by filename: "racecar.jpg"
Converts the attachment to plain text.
def to_plain_text if respond_to?(:attachable_plain_text_representation) attachable_plain_text_representation(caption) else caption.to_s end end