鉴于我有这样的模型:
class Person
has_many :owned_groups, :class_name => "Group", :foreign_key => :owner_id
has_many :owned_group_memberships, :through => :owned_groups,
:source => :group_memberships
has_many :group_memberships, :foreign_key => "member_id"
has_many :groups, :through => :group_memberships
end
class GroupMembership
belongs_to :member, :class_name => 'Person'
belongs_to :group
end
class Group
belongs_to :owner, :class_name => "Person"
has_many :group_memberships
has_many :members, :through => :group_memberships
end
如何访问members
a group
has?我总是这样做@group.members
或类似的事情,给我一个错误,说在模型中找不到关系。
提前致谢。
##编辑##
我得到的错误是:Could not find the association "group_memberships" in model Group