Class: Effective::Page

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.



3
4
5
# File 'app/models/effective/page.rb', line 3

def current_user
  @current_user
end

Returns the value of attribute menu_root_level.



4
5
6
# File 'app/models/effective/page.rb', line 4

def menu_root_level
  @menu_root_level
end

Instance Method Details

#bodyObject

As per has_many_rich_texts



87
88
89
# File 'app/models/effective/page.rb', line 87

def body
  rich_text_body
end

#duplicateObject

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

Returns:

  • (Boolean)


95
96
97
# File 'app/models/effective/page.rb', line 95

def published?
  !draft?
end


91
92
93
# File 'app/models/effective/page.rb', line 91

def sidebar
  rich_text_sidebar
end

#to_sObject



82
83
84
# File 'app/models/effective/page.rb', line 82

def to_s
  title
end