Merge pull request #50762 from p8/actiontext/document-associations-and-scopes

Document some ActionText methods [ci-skip]
This commit is contained in:
Petrik de Heus 2024-01-25 20:57:58 +01:00 committed by GitHub
commit 3c3df4cea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

@ -39,7 +39,16 @@ class RichText < Record
serialize :body, coder: ActionText::Content
delegate :to_s, :nil?, to: :body
##
# :method: record
#
# Returns the associated record.
belongs_to :record, polymorphic: true, touch: true
##
# :method: embeds
#
# Returns the <tt>ActiveStorage::Blob</tt>s of the embedded files.
has_many_attached :embeds
before_save do

@ -76,6 +76,7 @@ def with_all_rich_text
includes(rich_text_association_names)
end
# Returns the names of all rich text associations.
def rich_text_association_names
reflect_on_all_associations(:has_one).collect(&:name).select { |n| n.start_with?("rich_text_") }
end