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

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 Models::EventPublishable

#publish_event

Class Method Details

.sortedActiveRecord::Relation<ArticlePage>

A relation of ArticlePages that are sorted. Active Record Scope

Returns:

See Also:



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

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

Instance Method Details

#articleArticle

Returns:

See Also:



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

belongs_to :article

#localized_content(locale = nil) ⇒ Object

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



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

def localized_content(locale = nil)
  return unless content.present?

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

#localized_content_html_docObject



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

def localized_content_html_doc
  Nokogiri::HTML(localized_content)
end