给出以下模型关系。
// webpack.config.js
module.exports = {
...
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]
};
这是我做的事情
给定组是一个组对象
group has_many :members
member has_many :missions
mission has_one :game_set_mission
mission has_one :game_set, :through => :game_set_mission
但它似乎发生# Add a new relationship in member.rb
has_many :game_sets, :through => :missions
# Get all game_set id
group.members.map{ |gc| gc.game_sets.pluck(:id) }
。
如何改进我的代码?
答案 0 :(得分:0)
希望能帮助你。
GameSet.includes(member: :group)
.where('groups.id = ?', group.id)
.pluck('game_sets.id')