1
0
Fork 0
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:
George Claghorn 2018-12-21 00:59:43 -05:00
parent 086cc2b68e
commit 4d1f3f8324

View file

@ -9,11 +9,6 @@ class ActionText::RichText < ActiveRecord::Base
serialize :body, ActionText::Content
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
has_many_attached :embeds
@ -21,4 +16,10 @@ class ActionText::RichText < ActiveRecord::Base
before_save do
self.embeds = body.attachments.map(&:attachable) if body.present?
end
def to_plain_text
body&.to_plain_text.to_s
end
delegate :blank?, :empty?, :present?, to: :to_plain_text
end