Displaying 1 result from an estimated 1 matches for "active_membership".
2006 May 16
1
:conditions on has_one realationship
...all the memberships, but the most current
membership from the database on a per user basis. I have linked the
tables as shown:-
class Membership < ActiveRecord::Base
belongs_to :payment
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :memberships
has_one :active_membership, :class_name => ''Membership'', :order =>
''enddate DESC'', :conditions => ''memberships.id is not null and
memberships.enddate > now()''
end
As I understand it I should be able to do a
@people = Person.find :all, :include =>...