Class: ArticlePage

Inherits:
ApplicationRecord show all
Includes:
Models::Auditable
Defined in:
app/models/article_page.rb

Overview

== Schema Information

Table name: article_pages
Database name: primary

id :bigint not null, primary key
content :text not null
headline :text
position :integer not null
created_at :datetime not null
updated_at :datetime not null
article_id :integer not null

Indexes

index_article_pages_on_article_id_and_position (article_id,position) UNIQUE

Foreign Keys

fk_rails_... (article_id => articles.id) ON DELETE => cascade

Constant Summary

Constants included from Models::Auditable

Models::Auditable::ALWAYS_IGNORED

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Instance Attribute Summary collapse

Belongs to collapse

Methods included from Models::Auditable

#creator, #updater

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Auditable

#all_skipped_columns, #audit_reference_data, #should_not_save_version, #stamp_record

Methods inherited from ApplicationRecord

ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Instance Attribute Details

#contentObject (readonly)



28
# File 'app/models/article_page.rb', line 28

validates :content, presence: true

Class Method Details

.sortedActiveRecord::Relation<ArticlePage>

A relation of ArticlePages that are sorted. Active Record Scope

Returns:

See Also:



36
# File 'app/models/article_page.rb', line 36

scope :sorted, -> { order(:position) }

Instance Method Details

#articleArticle

Returns:

See Also:



26
# File 'app/models/article_page.rb', line 26

belongs_to :article

#localized_content(locale = nil) ⇒ Object

Any localized links in the article content will be prepended with the right locale



39
40
41
42
43
44
# File 'app/models/article_page.rb', line 39

def localized_content(locale = nil)
  return if content.blank?

  locale ||= I18n.locale
  content.gsub(/\{\{\s*locale\s*\}\}/, locale.to_s)
end

#localized_content_html_docObject



46
47
48
# File 'app/models/article_page.rb', line 46

def localized_content_html_doc
  Nokogiri::HTML(localized_content)
end