To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / vendor / plugins / acts_as_versioned / test / fixtures / page.rb @ 442:753f1380d6bc

History | View | Annotate | Download (1.11 KB)

1
class Page < ActiveRecord::Base
2
  belongs_to :author
3
  has_many   :authors,  :through => :versions, :order => 'name'
4
  belongs_to :revisor,  :class_name => 'Author'
5
  has_many   :revisors, :class_name => 'Author', :through => :versions, :order => 'name'
6
  acts_as_versioned :if => :feeling_good? do
7
    def self.included(base)
8
      base.cattr_accessor :feeling_good
9
      base.feeling_good = true
10
      base.belongs_to :author
11
      base.belongs_to :revisor, :class_name => 'Author'
12
    end
13
    
14
    def feeling_good?
15
      @@feeling_good == true
16
    end
17
  end
18
end
19

    
20
module LockedPageExtension
21
  def hello_world
22
    'hello_world'
23
  end
24
end
25

    
26
class LockedPage < ActiveRecord::Base
27
  acts_as_versioned \
28
    :inheritance_column => :version_type, 
29
    :foreign_key        => :page_id, 
30
    :table_name         => :locked_pages_revisions, 
31
    :class_name         => 'LockedPageRevision',
32
    :version_column     => :lock_version,
33
    :limit              => 2,
34
    :if_changed         => :title,
35
    :extend             => LockedPageExtension
36
end
37

    
38
class SpecialLockedPage < LockedPage
39
end
40

    
41
class Author < ActiveRecord::Base
42
  has_many :pages
43
end