所以如果我有以下关系
class Item < ActiveRecord::Base
has_many :item_user_relationships
has_many :users, :through => :item_user_relationships
end
class User < ActiveRecord::Base
has_many :item_user_relationships
has_many :items, :through => :item_user_relationships
end
class ItemUserRelationship < ActiveRecord::Base
belongs_to :item
belongs_to :user
attr_accessible :role
end
role
列出项目的所有用户时包含该属性的 Rails 方式是什么?
@users = @item.users # I want to include the role as part of a user
谢谢!
更新:我仍然有这个问题。我的目标是获得一组用户模型,它们的角色包含在属性中。