Class: Block
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Block
- Defined in:
- app/models/block.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ensure(sid, name, body, page_template_id = nil, show_editors = false, description = '') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/block.rb', line 26 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 |
Instance Method Details
#display_name ⇒ Object
12 13 14 |
# File 'app/models/block.rb', line 12 def display_name "Block" end |
#history ⇒ Object
22 23 24 |
# File 'app/models/block.rb', line 22 def history DesignHistory.sys(self.system_id).where(:model=>"Block").where(:model_id=>self.id).order("id desc") end |
#record_history ⇒ Object
16 17 18 19 20 |
# File 'app/models/block.rb', line 16 def record_history if self.changed.include?('body') DesignHistory.record(self) end end |
#render_preview(options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/models/block.rb', line 39 def render_preview() begin self.body.gsub(/\[\[([^\:]+)\:([^\:]+)\:[^\]]+\]\]/) do if $2=="friendly" [$1].friendly_format else [$1] end end rescue Exception => e logger.error(e) "[block error #{e.}]" end end |