aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures/developer.rb
blob: 336b48f087c9ecc69199f58bf6d4ff56e050f074 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Developer < ActiveRecord::Base
  has_and_belongs_to_many :projects, :extend => Module.new {
    def find_most_recent
      find(:first, :order => "id DESC")
    end
  }


  has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'

  validates_inclusion_of :salary, :in => 50000..200000
  validates_length_of    :name, :within => 3..20
end

DeveloperSalary = Struct.new(:amount)
class DeveloperWithAggregate < ActiveRecord::Base
  self.table_name = 'developers'
  composed_of :salary, :class_name => 'DeveloperSalary', :mapping => [%w(salary amount)]
end