多的has

编程入门 行业动态 更新时间:2024-10-08 02:22:57
本文介绍了多的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

本文发布于:2023-08-03 14:44:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1287751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!