使用嵌套的嵌套属性时,在rails中使用group

时间:2018-05-02 08:29:19

标签: ruby-on-rails activerecord group-by nested-attributes

我有这个模特

点 - > belongs_to:days

天 - > belongs_to:routes

我希望按点:address分组一种路线,我可以得到所有这些:

Point.includes(:day => :route).where(days:{routes:{place: "Dublin"}})

但如果我尝试使用group(:address),我会发现此错误:

ActiveRecord::StatementInvalid: PG::GroupingError: ERROR:  column 
"points.id" must appear in the GROUP BY clause or be used in an 
aggregate function
LINE 1: SELECT  "points"."id" AS t0_r0, "points"."title" AS t0_r1, 
"...
你可以帮帮我吗?感谢

0 个答案:

没有答案