Sha256: 019421fa720ca132bcf5d62476e94cc990dedd3764629a8ea48918c3d2c782a5
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
class SpudPagePartial < ActiveRecord::Base belongs_to :spud_page, touch: true has_many :spud_liquid_tags, as: :attachment, dependent: :destroy validates :name, presence: true before_save :maintain_revisions before_save :update_symbol_name acts_as_tb_liquid_content def update_symbol_name self.symbol_name = name.parameterize.underscore end def symbol_name return @symbol_name || name.parameterize.underscore end def postprocess_content @_template = Liquid::Template.parse(content) self.content_processed = @_template.render('page' => spud_page) end def content_processed=(content) self[:content_processed] = content end def content_processed if self[:content_processed].blank? if new_record? self.content_processed = postprocess_content() else update_column(:content_processed, postprocess_content) end end return self[:content_processed] end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tb_cms-1.3.0 | app/models/spud_page_partial.rb |
tb_cms-1.3.beta1 | app/models/spud_page_partial.rb |