例如,我有一个模型组和模型用户
它们与 :has_many, :through => groups_users 连接
groups_users 表有一个属性,称为 moderator,指定用户是否是组的主持人
问题:我如何访问给定组的所有版主?
在阅读了 :with_scope 之后,我想到的是
def find_moderators
Group.with_scope(:find=>{:conditions => "moderator=1"})
@moderators=@group.users
end
end
但是,在 rails 2 之后,with_scope 受到保护,并且不允许控制器中的给定代码,那么有什么好的替代方法呢?