Class: Thesis::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Thesis::Page
- Defined in:
- lib/thesis/models/page.rb
Instance Attribute Summary collapse
-
#editable ⇒ Object
Returns the value of attribute editable.
Instance Method Summary collapse
- #content(name, content_type = :html, opts = {}) ⇒ Object
- #path ⇒ Object
- #set_name ⇒ Object
- #update_slug ⇒ Object
- #update_subpage_slugs ⇒ Object
Instance Attribute Details
#editable ⇒ Object
Returns the value of attribute editable.
3 4 5 |
# File 'lib/thesis/models/page.rb', line 3 def editable @editable end |
Instance Method Details
#content(name, content_type = :html, opts = {}) ⇒ Object
35 36 37 |
# File 'lib/thesis/models/page.rb', line 35 def content(name, content_type = :html, opts = {}) find_or_create_page_content(name, content_type, opts).render(editable: self.editable) end |
#path ⇒ Object
39 40 41 |
# File 'lib/thesis/models/page.rb', line 39 def path self.slug end |
#set_name ⇒ Object
21 22 23 |
# File 'lib/thesis/models/page.rb', line 21 def set_name self.name ||= self.slug.to_s.split("/").last.to_s.humanize if self.slug end |
#update_slug ⇒ Object
25 26 27 28 29 |
# File 'lib/thesis/models/page.rb', line 25 def update_slug self.name ||= "" self.slug = "/" << self.name.parameterize self.slug = "#{parent.slug.to_s}#{self.slug.to_s}" if parent end |
#update_subpage_slugs ⇒ Object
31 32 33 |
# File 'lib/thesis/models/page.rb', line 31 def update_subpage_slugs subpages.each(&:save) if slug_changed? end |