solution but needs your judgment
class User < ActiveRecord::Base
has_many :memberships def find_recent_active_memberships
memberships.only_active.order_by_activity.limit(5) end end
class Membership < ActiveRecord::Base belongs_to :user scope :only_active, where(:active => true) scope :order_by_activity, order('last_active_on DESC') end