Class: Effective::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Page
- Defined in:
- app/models/effective/page.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
Returns the value of attribute current_user.
-
#menu_root_level ⇒ Object
This is for the form.
Instance Method Summary collapse
-
#body ⇒ Object
As per has_many_rich_texts.
-
#duplicate ⇒ Object
Returns a duplicated post object, or throws an exception.
- #duplicate! ⇒ Object
- #menu_child? ⇒ Boolean
- #menu_parent? ⇒ Boolean
- #menu_root? ⇒ Boolean
-
#menu_root_with_children? ⇒ Boolean
When true, this should not appear in sitemap.xml and should return 404 if visited.
- #menu_to_s ⇒ Object
- #published? ⇒ Boolean
- #sidebar ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
3 4 5 |
# File 'app/models/effective/page.rb', line 3 def current_user @current_user end |
#menu_root_level ⇒ Object
This is for the form
151 152 153 |
# File 'app/models/effective/page.rb', line 151 def @menu_root_level end |
Instance Method Details
#body ⇒ Object
As per has_many_rich_texts
115 116 117 |
# File 'app/models/effective/page.rb', line 115 def body rich_text_body end |
#duplicate ⇒ Object
Returns a duplicated post object, or throws an exception
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'app/models/effective/page.rb', line 128 def duplicate Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page| page.title = page.title + ' (Copy)' page.slug = page.slug + '-copy' rich_texts.each do |rt| page.send("rich_text_#{rt.name}=", rt.body) end page.draft = true end end |
#duplicate! ⇒ Object
141 142 143 |
# File 'app/models/effective/page.rb', line 141 def duplicate! duplicate.tap { |page| page.save! } end |
#menu_child? ⇒ Boolean
163 164 165 |
# File 'app/models/effective/page.rb', line 163 def && .present? end |
#menu_parent? ⇒ Boolean
159 160 161 |
# File 'app/models/effective/page.rb', line 159 def && .to_a.present? end |
#menu_root? ⇒ Boolean
155 156 157 |
# File 'app/models/effective/page.rb', line 155 def && .blank? end |
#menu_root_with_children? ⇒ Boolean
When true, this should not appear in sitemap.xml and should return 404 if visited
146 147 148 |
# File 'app/models/effective/page.rb', line 146 def && end |
#menu_to_s ⇒ Object
110 111 112 |
# File 'app/models/effective/page.rb', line 110 def (.presence || title) end |
#published? ⇒ Boolean
123 124 125 |
# File 'app/models/effective/page.rb', line 123 def published? !draft? end |
#sidebar ⇒ Object
119 120 121 |
# File 'app/models/effective/page.rb', line 119 def end |
#to_s ⇒ Object
106 107 108 |
# File 'app/models/effective/page.rb', line 106 def to_s title end |