新手问题 多态关联用起来倒是方便,但是查询怎么办呢?

ampedxx · November 12, 2017 · Last by IChou replied at November 13, 2017 · 2087 hits

最近遇到一个特别蛋疼的问题:有一张表 agency_matters 是多态关联的。所以我需要很多种不同的关联这张表 (agency_matters) 的姿势: 第一种姿势:ApplyForm.left_joins(plans: [process_works: [child_process_works: [:agency_matters]]) 第二种姿势:ApplyForm.left_joins(student: [attachment_groups:[:agency_matters]]) 第三种姿势:ApplyForm.left_joins( closures: [:agency_matters]) 能不能在一个查询语句里面用三种不同的姿势 left_join 上 agency_matter 表。写 SQL 语句的话倒是可以,但是直接用 Ruby 应该怎么写呢?

模型间的关联关系到底是怎么样的,可以表述清楚一点么

You need to Sign in before reply, if you don't have an account, please Sign up first.