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
Returns the value of attribute menu_root_level.
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
- #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
Returns the value of attribute menu_root_level.
4 5 6 |
# File 'app/models/effective/page.rb', line 4 def @menu_root_level end |
Instance Method Details
#body ⇒ Object
As per has_many_rich_texts
87 88 89 |
# File 'app/models/effective/page.rb', line 87 def body rich_text_body end |
#duplicate ⇒ Object
Returns a duplicated post object, or throws an exception
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/models/effective/page.rb', line 100 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
113 114 115 |
# File 'app/models/effective/page.rb', line 113 def duplicate! duplicate.tap { |page| page.save! } end |
#published? ⇒ Boolean
95 96 97 |
# File 'app/models/effective/page.rb', line 95 def published? !draft? end |
#sidebar ⇒ Object
91 92 93 |
# File 'app/models/effective/page.rb', line 91 def end |
#to_s ⇒ Object
82 83 84 |
# File 'app/models/effective/page.rb', line 82 def to_s title end |