本文介绍了多的has_many:通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在对象模型中,我有
has_many :likes has_many :hates has_many :users, :through => :likes has_many :users, :through => :hates
如何获得用户的喜好名单?例如。 object.users< ---但我怎么喜欢通过指定或不喜欢
How do I get the list of users for likes? E.g. object.users <--- but how do I specify through likes or hates?
推荐答案您需要给这两个不同的协会不同的名字。怎么样
You need to give these two different associations different names. What about
has_many :likes has_many :hates has_many :likers, :through => :likes, :source => :user has_many :haters, :through => :hates, :source => :user更多推荐
多的has
发布评论