2004-11-23 20:04:44 -05:00
class Project < ActiveRecord :: Base
2006-05-06 22:03:25 -04:00
has_and_belongs_to_many :developers , :uniq = > true , :order = > 'developers.name desc, developers.id desc'
2008-02-13 01:32:50 -05:00
has_and_belongs_to_many :readonly_developers , :class_name = > " Developer " , :readonly = > true
2007-12-05 16:37:51 -05:00
has_and_belongs_to_many :selected_developers , :class_name = > " Developer " , :select = > " developers.* " , :uniq = > true
2006-05-06 22:03:25 -04:00
has_and_belongs_to_many :non_unique_developers , :order = > 'developers.name desc, developers.id desc' , :class_name = > 'Developer'
2005-12-12 19:39:51 -05:00
has_and_belongs_to_many :limited_developers , :class_name = > " Developer " , :limit = > 1
2004-11-23 20:04:44 -05:00
has_and_belongs_to_many :developers_named_david , :class_name = > " Developer " , :conditions = > " name = 'David' " , :uniq = > true
2006-09-01 01:31:56 -04:00
has_and_belongs_to_many :developers_named_david_with_hash_conditions , :class_name = > " Developer " , :conditions = > { :name = > 'David' } , :uniq = > true
2005-06-13 17:51:43 -04:00
has_and_belongs_to_many :salaried_developers , :class_name = > " Developer " , :conditions = > " salary > 0 "
2008-08-22 02:53:59 -04:00
has_and_belongs_to_many :developers_with_finder_sql , :class_name = > " Developer " , :finder_sql = > 'SELECT t.*, j.* FROM developers_projects j, developers t WHERE t.id = j.developer_id AND j.project_id = #{id} ORDER BY t.id'
2009-06-30 18:55:09 -04:00
has_and_belongs_to_many :developers_with_multiline_finder_sql , :class_name = > " Developer " , :finder_sql = > '
SELECT
t . * , j . *
FROM
developers_projects j ,
developers t WHERE t . id = j . developer_id AND j . project_id = #{id} ORDER BY t.id'
2005-05-19 13:07:56 -04:00
has_and_belongs_to_many :developers_by_sql , :class_name = > " Developer " , :delete_sql = > " DELETE FROM developers_projects WHERE project_id = \# {id} AND developer_id = \# {record.id} "
2007-10-16 01:07:58 -04:00
has_and_belongs_to_many :developers_with_callbacks , :class_name = > " Developer " , :before_add = > Proc . new { | o , r | o . developers_log << " before_adding #{ r . id || '<new>' } " } ,
:after_add = > Proc . new { | o , r | o . developers_log << " after_adding #{ r . id || '<new>' } " } ,
2005-07-04 04:43:57 -04:00
:before_remove = > Proc . new { | o , r | o . developers_log << " before_removing #{ r . id } " } ,
:after_remove = > Proc . new { | o , r | o . developers_log << " after_removing #{ r . id } " }
2009-04-21 08:06:26 -04:00
has_and_belongs_to_many :well_payed_salary_groups , :class_name = > " Developer " , :group = > " developers.salary " , :having = > " SUM(salary) > 10000 " , :select = > " SUM(salary) as salary "
2005-07-04 04:43:57 -04:00
attr_accessor :developers_log
2009-09-08 11:22:45 -04:00
after_initialize :set_developers_log
2005-07-04 04:43:57 -04:00
2009-09-08 11:22:45 -04:00
def set_developers_log
2005-07-04 04:43:57 -04:00
@developers_log = [ ]
end
2004-12-14 07:32:29 -05:00
end
class SpecialProject < Project
def hello_world
" hello there! "
end
2005-06-13 17:51:43 -04:00
end