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
- #published? ⇒ Boolean
- #sidebar ⇒ Object
- #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
185 186 187 |
# File 'app/models/effective/page.rb', line 185 def @menu_root_level end |
Instance Method Details
#body ⇒ Object
As per has_many_rich_texts
149 150 151 |
# File 'app/models/effective/page.rb', line 149 def body rich_text_body end |
#duplicate ⇒ Object
Returns a duplicated post object, or throws an exception
162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'app/models/effective/page.rb', line 162 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
175 176 177 |
# File 'app/models/effective/page.rb', line 175 def duplicate! duplicate.tap { |page| page.save! } end |
#menu_child? ⇒ Boolean
197 198 199 |
# File 'app/models/effective/page.rb', line 197 def && .present? end |
#menu_children_blank? ⇒ Boolean
205 206 207 |
# File 'app/models/effective/page.rb', line 205 def <= 0 end |
#menu_children_present? ⇒ Boolean
201 202 203 |
# File 'app/models/effective/page.rb', line 201 def > 0 end |
#menu_parent? ⇒ Boolean
193 194 195 |
# File 'app/models/effective/page.rb', line 193 def && end |
#menu_root? ⇒ Boolean
189 190 191 |
# File 'app/models/effective/page.rb', line 189 def && .blank? end |
#menu_root_with_children? ⇒ Boolean
When true, this should not appear in sitemap.xml and should return 404 if visited
180 181 182 |
# File 'app/models/effective/page.rb', line 180 def && end |
#menu_to_s ⇒ Object
144 145 146 |
# File 'app/models/effective/page.rb', line 144 def (.presence || title) end |
#published? ⇒ Boolean
157 158 159 |
# File 'app/models/effective/page.rb', line 157 def published? !draft? end |
#sidebar ⇒ Object
153 154 155 |
# File 'app/models/effective/page.rb', line 153 def end |
#to_s ⇒ Object
140 141 142 |
# File 'app/models/effective/page.rb', line 140 def to_s title end |