Class: Decidim::StaticPage
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::StaticPage
- Includes:
- Loggable, Traceable, TranslatableResource
- Defined in:
- app/models/decidim/static_page.rb
Overview
A page is used to add static content to the website, it can be useful so organization can add their own terms and conditions, privacy policy or other pages they might need from an admin panel.
Pages with a default slug cannot be destroyed and its slug cannot be modified.
Constant Summary collapse
- DEFAULT_PAGES =
These pages will be created by default when registering an organization and cannot be deleted.
%w(terms-and-conditions).freeze
Class Method Summary collapse
-
.default?(slug) ⇒ Boolean
Whether this is slug of a default page or not.
- .log_presenter_class_for(_log) ⇒ Object
- .sorted_by_i18n_title(locale = I18n.locale) ⇒ Object
Instance Method Summary collapse
-
#default? ⇒ Boolean
Whether this is page is a default one or not.
-
#to_param ⇒ Object
Customize to_param so when we want to create a link to a page we use the slug instead of the id.
Class Method Details
.default?(slug) ⇒ Boolean
Whether this is slug of a default page or not.
slug - The String with the value of the slug.
Returns Boolean.
48 49 50 |
# File 'app/models/decidim/static_page.rb', line 48 def self.default?(slug) DEFAULT_PAGES.include?(slug) end |
.log_presenter_class_for(_log) ⇒ Object
52 53 54 |
# File 'app/models/decidim/static_page.rb', line 52 def self.log_presenter_class_for(_log) Decidim::AdminLog::StaticPagePresenter end |
.sorted_by_i18n_title(locale = I18n.locale) ⇒ Object
56 57 58 |
# File 'app/models/decidim/static_page.rb', line 56 def self.sorted_by_i18n_title(locale = I18n.locale) order([Arel.sql("title->? ASC"), locale]) end |
Instance Method Details
#default? ⇒ Boolean
Whether this is page is a default one or not.
Returns Boolean.
63 64 65 |
# File 'app/models/decidim/static_page.rb', line 63 def default? self.class.default?(slug) end |
#to_param ⇒ Object
Customize to_param so when we want to create a link to a page we use the slug instead of the id.
Returns a String.
71 72 73 |
# File 'app/models/decidim/static_page.rb', line 71 def to_param slug end |