Class: Effective::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Effective::Page
- Defined in:
- app/models/effective/page.rb
Instance Method Summary collapse
-
#duplicate! ⇒ Object
Returns a duplicated post object, or throws an exception.
- #published? ⇒ Boolean
- #to_s ⇒ Object
Instance Method Details
#duplicate! ⇒ Object
Returns a duplicated post object, or throws an exception
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/effective/page.rb', line 46 def duplicate! Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page| page.title = page.title + ' (Copy)' page.slug = page.slug + '-copy' page.draft = true regions.each do |region| page.regions.build(region.attributes.except('id', 'updated_at', 'created_at')) end page.save! end end |
#published? ⇒ Boolean
41 42 43 |
# File 'app/models/effective/page.rb', line 41 def published? !draft? end |
#to_s ⇒ Object
37 38 39 |
# File 'app/models/effective/page.rb', line 37 def to_s title end |