Module: IrwiMod::Extensions::Models::WikiPage

Defined in:
lib/irwi_mod/extensions/models/wiki_page.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/irwi_mod/extensions/models/wiki_page.rb', line 33

def self.included( base )
  base.send :extend, IrwiMod::Extensions::Models::WikiPage::ClassMethods
  base.send :include, IrwiMod::Extensions::Models::WikiPage::InstanceMethods

  base.attr_protected :id

  base.send :attr_accessor, :comment, :previous_version_number

  base.belongs_to :creator, :class_name => IrwiMod.config.user_class_name
  base.belongs_to :updator, :class_name => IrwiMod.config.user_class_name

  base.has_many :versions, :class_name => IrwiMod.config.page_version_class_name, :foreign_key => IrwiMod.config.page_version_foreign_key, :order => 'id DESC'

  if IrwiMod::config.page_attachment_class_name
    base.has_many :attachments, :class_name => IrwiMod.config.page_attachment_class_name, :foreign_key => IrwiMod.config.page_version_foreign_key
  end

  base.before_save {|record| record.content = '' if record.content.nil? }
  base.before_save {|record| record.path = record.title} #Change by RH - I have to save the path
  base.after_save :create_new_version
end