Sha256: 748827e1cc0dd91375b5a4bcaa089498dad2e52df7916bdc8b48263d7526beda
Contents?: true
Size: 1.1 KB
Versions: 4
Compression:
Stored size: 1.1 KB
Contents
class Block < ActiveRecord::Base has_and_belongs_to_many :page_templates validates :name, :presence=>true, :length=>{:minimum=>1, :maximum=>80} belongs_to :user use_kit_caching before_save :record_history def display_name "Block" end def record_history if self.changed.include?('body') DesignHistory.record(self) end end def history DesignHistory.sys(self.system_id).where(:model=>"Block").where(:model_id=>self.id).order("id desc") end def self.ensure(sid, name, body, page_template_id = nil, show_editors = false, description = '') return if Block.where(:name=>name).sys(sid).count>0 b = Block.new b.system_id = sid b.name = name b.description = description b.body = body b.show_editors = show_editors b.save end def render_preview(options) begin self.body.gsub(/\[\[([^\:]+)\:([^\:]+)\:[^\]]+\]\]/) do if $2=="friendly" options[$1].friendly_format else options[$1] end end rescue Exception => e logger.error(e) "[block error #{e.message}]" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kit_cms-2.3.9 | app/models/block.rb |
kit_cms-2.3.8 | app/models/block.rb |
kit_cms-2.3.7 | app/models/block.rb |
kit_cms-2.3.6 | app/models/block.rb |