0
爲我的用戶的模式,我有:導軌 - 命名範圍
class User < ActiveRecord::Base
has_many :group_users, :class_name => "User", :finder_sql => 'select DISTINCT u.* from users u join permissions pp on pp.user_id=u.id join spaces p on pp.space_id=p.id where space_id in (select space_id from permissions pp2 where user_id=#{id}) and pp.user_id != #{id}'
我如何可以訪問像一個範圍:
scope :usersInMySpaces, lambda { |user|
group_users
}
感謝
您只需要知道:http://www.railway.at/2010/03/09/named-scopes-are-dead/ – Zabba 2011-01-22 06:09:37