Class: BillyCms::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- BillyCms::Page
- Extended by:
- FriendlyId
- Defined in:
- app/models/billy_cms/page.rb
Instance Method Summary collapse
- #additional_attribute(attribute_name) ⇒ Object
- #additional_attributes ⇒ Object
- #binaries ⇒ Object
- #binary? ⇒ Boolean
- #boxes ⇒ Object
- #children ⇒ Object
- #cms_path ⇒ Object
- #is_in_path?(path) ⇒ Boolean
- #navigation ⇒ Object
- #sibblings ⇒ Object
Instance Method Details
#additional_attribute(attribute_name) ⇒ Object
54 55 56 |
# File 'app/models/billy_cms/page.rb', line 54 def additional_attribute(attribute_name) self.additional_attributes_values[attribute_name.to_s] if self.additional_attributes_values.present? end |
#additional_attributes ⇒ Object
48 49 50 51 52 |
# File 'app/models/billy_cms/page.rb', line 48 def additional_attributes type = PageType.find_by_name(self.page_type) return [] unless type.present? type.additional_attributes end |
#binaries ⇒ Object
27 28 29 |
# File 'app/models/billy_cms/page.rb', line 27 def binaries pages.where(page_type: 'Binary').sort_by(&:order_key) end |
#binary? ⇒ Boolean
44 45 46 |
# File 'app/models/billy_cms/page.rb', line 44 def binary? self.page_type == 'Binary' end |
#boxes ⇒ Object
23 24 25 |
# File 'app/models/billy_cms/page.rb', line 23 def boxes pages.where(page_type: 'box').sort_by(&:order_key) end |
#children ⇒ Object
15 16 17 |
# File 'app/models/billy_cms/page.rb', line 15 def children pages.sort_by(&:order_key) end |
#cms_path ⇒ Object
11 12 13 |
# File 'app/models/billy_cms/page.rb', line 11 def cms_path get_cms_path_component_for_parent '', self end |
#is_in_path?(path) ⇒ Boolean
31 32 33 34 35 36 37 38 |
# File 'app/models/billy_cms/page.rb', line 31 def is_in_path?(path) if path == '/' return slug == 'startseite' ? true : false end # byebug if id == 6 reg = Regexp.new("^(#{cms_path})", 'i') path.match(reg) != nil end |
#navigation ⇒ Object
19 20 21 |
# File 'app/models/billy_cms/page.rb', line 19 def self.children.reject { |page| page. || page.page_type == 'Binary' || page.page_type == 'Box' } end |
#sibblings ⇒ Object
40 41 42 |
# File 'app/models/billy_cms/page.rb', line 40 def sibblings self.class.where(parent_page_id: parent_page_id).where.not(id: id).order(:order_key) end |