Class: PageVersion
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- PageVersion
show all
- Includes:
- Trek::Sectionable
- Defined in:
- lib/generators/trek/templates/models/page_version.rb
Overview
‘PageVersion` is a version of a `Page`. There’s always only one ‘current` version per page, and there can be other versions. Any version can be promoted to `current`.
Constant Summary
Trek::Sectionable::SECTIONS, Trek::Sectionable::SECTION_NAMES
Instance Method Summary
collapse
Instance Method Details
#current? ⇒ Boolean
25
26
27
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 25
def current?
current_since?
end
|
#current_image ⇒ Object
29
30
31
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 29
def current_image
image
end
|
#current_image_url ⇒ Object
33
34
35
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 33
def current_image_url
image_url
end
|
#other_versions ⇒ Object
37
38
39
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 37
def other_versions
page.versions.where.not(id:)
end
|
#set_default_name ⇒ Object
41
42
43
44
45
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 41
def set_default_name
return if page.blank?
self.name ||= "#{page.title} (#{I18n.l(Time.zone.now.to_date)})"
end
|
#to_s ⇒ Object
21
22
23
|
# File 'lib/generators/trek/templates/models/page_version.rb', line 21
def to_s
name
end
|