Forum: Ruby on Rails Extending ActiveRecord Extensions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jordan M. (Guest)
on 2007-03-15 22:39
Let's say I've got a table of people.  Each person is either male or
female and single or not single.  I can get methods like:

group.people.male
group.people.female
group.people.single

By using extensions a la:

class Group < ActiveRecord::Base
  has_many :people do
    def single
      find :all, :conditions=>{:single=>true}
    end
end

But what if I wanted methods like:

group.people.female.single

Is there a way to extend the extensions at all? It seems like this
functionality would be very helpful to encapsulate everything so you
don't end up with methods like

group.people.female_and_single
group.people.male_and_not_single

Thoughts?
This topic is locked and can not be replied to.