Sha256: 8b889c433d84f5fd8bcd489a5a47b97460d704011490bb793e7b8c0bf0ecbfd4

Contents?: true

Size: 817 Bytes

Versions: 8

Compression:

Stored size: 817 Bytes

Contents

class SpudPagePartial < ActiveRecord::Base
	belongs_to :spud_page
	attr_accessible :name,:spud_page_id,:content,:format
	before_save :maintain_revisions


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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
spud_cms-0.8.17 app/models/spud_page_partial.rb
spud_cms-0.8.15 app/models/spud_page_partial.rb
spud_cms-0.8.14 app/models/spud_page_partial.rb
spud_cms-0.8.13 app/models/spud_page_partial.rb
spud_cms-0.8.12 app/models/spud_page_partial.rb
spud_cms-0.8.11 app/models/spud_page_partial.rb
spud_cms-0.8.10 app/models/spud_page_partial.rb
spud_cms-0.8.9 app/models/spud_page_partial.rb