Files
fizzy/app/models/concerns/attachments.rb
T
Jason Zimdars 97e20c5cd7 Make nil safe
2025-07-08 16:57:48 -05:00

20 lines
405 B
Ruby

module Attachments
extend ActiveSupport::Concern
def attachments
rich_text_record&.embeds || []
end
def has_attachments?
attachments.any?
end
private
def rich_text_record
@rich_text_record ||= begin
association = self.class.reflect_on_all_associations(:has_one).find { it.klass == ActionText::RichText }
public_send(association.name)
end
end
end