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
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
- #content ⇒ Object readonly
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 Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#content ⇒ Object (readonly)
28 |
# File 'app/models/article_page.rb', line 28 validates :content, presence: true |
Class Method Details
.sorted ⇒ ActiveRecord::Relation<ArticlePage>
A relation of ArticlePages that are sorted. Active Record Scope
36 |
# File 'app/models/article_page.rb', line 36 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
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_doc ⇒ Object
46 47 48 |
# File 'app/models/article_page.rb', line 46 def localized_content_html_doc Nokogiri::HTML(localized_content) end |