mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Move method definition below callbacks
This commit is contained in:
parent
086cc2b68e
commit
4d1f3f8324
1 changed files with 6 additions and 5 deletions
|
@ -9,11 +9,6 @@ class ActionText::RichText < ActiveRecord::Base
|
||||||
|
|
||||||
serialize :body, ActionText::Content
|
serialize :body, ActionText::Content
|
||||||
delegate :to_s, :nil?, to: :body
|
delegate :to_s, :nil?, to: :body
|
||||||
delegate :blank?, :empty?, :present?, to: :to_plain_text
|
|
||||||
|
|
||||||
def to_plain_text
|
|
||||||
body&.to_plain_text.to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
belongs_to :record, polymorphic: true, touch: true
|
belongs_to :record, polymorphic: true, touch: true
|
||||||
has_many_attached :embeds
|
has_many_attached :embeds
|
||||||
|
@ -21,4 +16,10 @@ class ActionText::RichText < ActiveRecord::Base
|
||||||
before_save do
|
before_save do
|
||||||
self.embeds = body.attachments.map(&:attachable) if body.present?
|
self.embeds = body.attachments.map(&:attachable) if body.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_plain_text
|
||||||
|
body&.to_plain_text.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
delegate :blank?, :empty?, :present?, to: :to_plain_text
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue