2022-04-19 04:38:49 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class StepText < ApplicationRecord
|
|
|
|
include TinyMceImages
|
2022-06-02 17:15:32 +08:00
|
|
|
include ActionView::Helpers::TextHelper
|
2022-04-19 04:38:49 +08:00
|
|
|
|
|
|
|
auto_strip_attributes :text, nullify: false
|
|
|
|
validates :text, length: { maximum: Constants::RICH_TEXT_MAX_LENGTH }
|
|
|
|
|
|
|
|
belongs_to :step, inverse_of: :step_texts, touch: true
|
2022-07-20 16:14:48 +08:00
|
|
|
has_one :step_orderable_element, as: :orderable, dependent: :destroy
|
2022-06-02 17:15:32 +08:00
|
|
|
|
2022-06-08 21:55:50 +08:00
|
|
|
scope :asc, -> { order('step_texts.created_at ASC') }
|
|
|
|
|
2022-06-02 17:15:32 +08:00
|
|
|
def name
|
2022-06-02 17:32:31 +08:00
|
|
|
return if text.blank?
|
|
|
|
|
2022-06-02 17:15:32 +08:00
|
|
|
strip_tags(text.truncate(64))
|
|
|
|
end
|
2022-04-19 04:38:49 +08:00
|
|
|
end
|