Class: Effective::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
PgSearch::Model
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.



11
12
13
# File 'app/models/effective/page.rb', line 11

def current_user
  @current_user
end

This is for the form



176
177
178
# File 'app/models/effective/page.rb', line 176

def menu_root_level
  @menu_root_level
end

Instance Method Details

#bodyObject

As per has_many_rich_texts



140
141
142
# File 'app/models/effective/page.rb', line 140

def body
  rich_text_body
end

#duplicateObject

Returns a duplicated post object, or throws an exception



153
154
155
156
157
158
159
160
161
162
163
164
# File 'app/models/effective/page.rb', line 153

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



166
167
168
# File 'app/models/effective/page.rb', line 166

def duplicate!
  duplicate.tap { |page| page.save! }
end

Returns:

  • (Boolean)


188
189
190
# File 'app/models/effective/page.rb', line 188

def menu_child?
  menu? && menu_parent_id.present?
end

Returns:

  • (Boolean)


184
185
186
# File 'app/models/effective/page.rb', line 184

def menu_parent?
  menu? && menu_children.to_a.present?
end

Returns:

  • (Boolean)


180
181
182
# File 'app/models/effective/page.rb', line 180

def menu_root?
  menu? && menu_parent_id.blank?
end

When true, this should not appear in sitemap.xml and should return 404 if visited

Returns:

  • (Boolean)


171
172
173
# File 'app/models/effective/page.rb', line 171

def menu_root_with_children?
  menu_root? && menu_parent?
end


135
136
137
# File 'app/models/effective/page.rb', line 135

def menu_to_s
  (menu_title.presence || title)
end

#published?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'app/models/effective/page.rb', line 148

def published?
  !draft?
end


144
145
146
# File 'app/models/effective/page.rb', line 144

def sidebar
  rich_text_sidebar
end

#to_sObject



131
132
133
# File 'app/models/effective/page.rb', line 131

def to_s
  title
end