Class: Effective::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Page
- Includes:
- PgSearch::Model
- 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_children_blank? ⇒ Boolean
- #menu_children_present? ⇒ 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
- #sidebar ⇒ Object
-
#template_page_segments? ⇒ Boolean
Checked by render_page_segments_menu() to see if this page should render the page_segments menu.
- #to_s ⇒ Object
Instance Attribute Details
#current_user ⇒ Object
Returns the value of attribute current_user.
11 12 13 |
# File 'app/models/effective/page.rb', line 11 def current_user @current_user end |
#menu_root_level ⇒ Object
This is for the form
183 184 185 |
# File 'app/models/effective/page.rb', line 183 def @menu_root_level end |
Instance Method Details
#body ⇒ Object
As per has_many_rich_texts
151 152 153 |
# File 'app/models/effective/page.rb', line 151 def body rich_text_body end |
#duplicate ⇒ Object
Returns a duplicated post object, or throws an exception
160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'app/models/effective/page.rb', line 160 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.assign_attributes(published_start_at: nil, published_end_at: nil) end end |
#duplicate! ⇒ Object
173 174 175 |
# File 'app/models/effective/page.rb', line 173 def duplicate! duplicate.tap { |page| page.save! } end |
#menu_child? ⇒ Boolean
195 196 197 |
# File 'app/models/effective/page.rb', line 195 def && .present? end |
#menu_children_blank? ⇒ Boolean
203 204 205 |
# File 'app/models/effective/page.rb', line 203 def <= 0 end |
#menu_children_present? ⇒ Boolean
199 200 201 |
# File 'app/models/effective/page.rb', line 199 def > 0 end |
#menu_parent? ⇒ Boolean
191 192 193 |
# File 'app/models/effective/page.rb', line 191 def && end |
#menu_root? ⇒ Boolean
187 188 189 |
# File 'app/models/effective/page.rb', line 187 def && .blank? end |
#menu_root_with_children? ⇒ Boolean
When true, this should not appear in sitemap.xml and should return 404 if visited
178 179 180 |
# File 'app/models/effective/page.rb', line 178 def && end |
#menu_to_s ⇒ Object
146 147 148 |
# File 'app/models/effective/page.rb', line 146 def (.presence || title) end |
#sidebar ⇒ Object
155 156 157 |
# File 'app/models/effective/page.rb', line 155 def end |
#template_page_segments? ⇒ Boolean
Checked by render_page_segments_menu() to see if this page should render the page_segments menu
208 209 210 |
# File 'app/models/effective/page.rb', line 208 def template_page_segments? template == 'page_segments' end |
#to_s ⇒ Object
142 143 144 |
# File 'app/models/effective/page.rb', line 142 def to_s title.presence || model_name.human end |