Class: Decidim::StaticPage
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::StaticPage
- 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(faq terms-and-conditions accessibility).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.
35 36 37 |
# File 'app/models/decidim/static_page.rb', line 35 def self.default?(slug) DEFAULT_PAGES.include?(slug) end |
.log_presenter_class_for(_log) ⇒ Object
39 40 41 |
# File 'app/models/decidim/static_page.rb', line 39 def self.log_presenter_class_for(_log) Decidim::AdminLog::StaticPagePresenter end |
.sorted_by_i18n_title(locale = I18n.locale) ⇒ Object
43 44 45 |
# File 'app/models/decidim/static_page.rb', line 43 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.
50 51 52 |
# File 'app/models/decidim/static_page.rb', line 50 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.
58 59 60 |
# File 'app/models/decidim/static_page.rb', line 58 def to_param slug end |