【发布时间】:2019-09-30 12:47:47
【问题描述】:
我有一个 User 模型和一个 SkillList 模型。
协会 - has_many / belongs_to.
所以我可以找到一个用户的技能列表条目:
current_user.skill_list
用户表有字段:id、name 和 location。
我需要查询数据库找到所有有位置和技能的用户。
我可以找到所有具有现有位置的用户(不包括当前用户):
users = User.where.not(location: nil, id: current_user.id)
但是如何排除没有技能的用户呢?
【问题讨论】:
标签: sql ruby-on-rails ruby associations