mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-15 13:45:25 +08:00
20 lines
520 B
Ruby
20 lines
520 B
Ruby
# frozen_string_literal: true
|
|
|
|
class StepText < ApplicationRecord
|
|
include TinyMceImages
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
auto_strip_attributes :text, nullify: false
|
|
validates :text, length: { maximum: Constants::RICH_TEXT_MAX_LENGTH }
|
|
|
|
belongs_to :step, inverse_of: :step_texts, touch: true
|
|
has_one :step_orderable_element, as: :orderable, dependent: :destroy
|
|
|
|
scope :asc, -> { order('step_texts.created_at ASC') }
|
|
|
|
def name
|
|
return if text.blank?
|
|
|
|
strip_tags(text.truncate(64))
|
|
end
|
|
end
|