Class: Effective::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/page.rb

Instance Method Summary collapse

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_sObject



37
38
39
# File 'app/models/effective/page.rb', line 37

def to_s
  title
end