Class: SpudPagePartial

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

Instance Method Summary collapse

Instance Method Details

#content_processedObject



15
16
17
18
# File 'app/models/spud_page_partial.rb', line 15

def content_processed
  ActiveSupport::Deprecation.warn('#content_processed is deprecated; use #content instead.')
  content
end

#maintain_revisionsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/spud_page_partial.rb', line 20

def maintain_revisions
  return true unless changed.include?('content')
  revision = SpudPagePartialRevision.new(spud_page_id: spud_page_id, name: name, format: format, content: content)
  revision.save
  if Spud::Cms.max_revisions > 0
    revision_count = SpudPagePartialRevision.where(spud_page_id: spud_page_id, name: name).count
    if revision_count > Spud::Cms.max_revisions
      revision_bye = SpudPagePartialRevision.where(spud_page_id: spud_page_id, name: name).order('created_at ASC').first
      revision_bye.destroy unless revision_bye.blank?
    end
  end
  return true
end

#symbol_nameObject



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

def symbol_name
  return @symbol_name || name.parameterize.underscore
end

#update_symbol_nameObject



7
8
9
# File 'app/models/spud_page_partial.rb', line 7

def update_symbol_name
  self.symbol_name = name.parameterize.underscore
end