Class: ArticlePage
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ArticlePage
- 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
Class Method Summary collapse
-
.sorted ⇒ ActiveRecord::Relation<ArticlePage>
A relation of ArticlePages that are sorted.
Instance Method Summary collapse
-
#localized_content(locale = nil) ⇒ Object
Any localized links in the article content will be prepended with the right locale.
- #localized_content_html_doc ⇒ Object
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
Class Method Details
.sorted ⇒ ActiveRecord::Relation<ArticlePage>
A relation of ArticlePages that are sorted. Active Record Scope
35 |
# File 'app/models/article_page.rb', line 35 scope :sorted, -> { order(:position) } |
Instance Method Details
#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_doc ⇒ Object
45 46 47 |
# File 'app/models/article_page.rb', line 45 def localized_content_html_doc Nokogiri::HTML(localized_content) end |