module ActivityMethods
def self.included(base)
base.send :include, InstanceMethods
base.has_many :activity_memberships
base.has_many :members, :through => :activity_memberships, :source => :user
end
end
:source
Specifies the source association name used by has_many :through queries. Only use it if the name cannot be inferred from the association. has_many :subscribers, :through => :subscriptions will look for either :subscribers or :subscriber on Subscription, unless
a :source is given.
:source 指定has_many :through查询的源关联名。 只有在关联名和所要关联的类名不相关的时候才需要用到. 如果没有指定:source,那么has_many :subscribers, :through => :subscriptions会去查找subscription上边的:subscribers或者:subscriber关联,假设设置了:source => :user,则会去查找:subscription上的:user关联