2004-11-23 20:04:44 -05:00
class Project < ActiveRecord :: Base
2013-03-12 05:23:08 -04:00
has_and_belongs_to_many :developers , - > { distinct . order 'developers.name desc, developers.id desc' }
2012-07-13 14:34:40 -04:00
has_and_belongs_to_many :readonly_developers , - > { readonly } , :class_name = > " Developer "
2013-08-17 12:08:53 -04:00
has_and_belongs_to_many :selected_developers , - > { distinct . select " developers.* " } , :class_name = > " Developer "
2012-07-13 14:34:40 -04:00
has_and_belongs_to_many :non_unique_developers , - > { order 'developers.name desc, developers.id desc' } , :class_name = > 'Developer'
has_and_belongs_to_many :limited_developers , - > { limit 1 } , :class_name = > " Developer "
2013-03-12 05:23:08 -04:00
has_and_belongs_to_many :developers_named_david , - > { where ( " name = 'David' " ) . distinct } , :class_name = > " Developer "
has_and_belongs_to_many :developers_named_david_with_hash_conditions , - > { where ( :name = > 'David' ) . distinct } , :class_name = > " Developer "
2012-07-13 14:34:40 -04:00
has_and_belongs_to_many :salaried_developers , - > { where " salary > 0 " } , :class_name = > " Developer "
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 } " }
2012-07-13 14:34:40 -04:00
has_and_belongs_to_many :well_payed_salary_groups , - > { group ( " developers.salary " ) . having ( " SUM(salary) > 10000 " ) . select ( " SUM(salary) as salary " ) } , :class_name = > " Developer "
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
2011-01-02 15:33:18 -05:00
def self . all_as_method
all
end
2012-07-27 12:27:47 -04:00
scope :all_as_scope , - > { all }
2004-12-14 07:32:29 -05:00
end
class SpecialProject < Project
2005-06-13 17:51:43 -04:00
end