Sha256: c9878d05b340576e7d5690e06af8223a9c40cc840abcaca40435ec77319e191e

Contents?: true

Size: 638 Bytes

Versions: 1

Compression:

Stored size: 638 Bytes

Contents

class SpudSnippet < ActiveRecord::Base

  validates :name, :presence => true
  validates_uniqueness_of :name, :scope => :site_id

  scope :site, lambda {|sid| where(:site_id => sid)}

  acts_as_tb_liquid_content

  def postprocess_content
    template = Liquid::Template.parse(self.content)
    self.content_processed = template.render()
  end

  def content_processed=(content)
    write_attribute(:content_processed,content)
  end

  def content_processed
    if read_attribute(:content_processed).blank?
      self.update_column(:content_processed, postprocess_content)
    end
    return read_attribute(:content_processed)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tb_cms-1.2.0.beta1 app/models/spud_snippet.rb