2
我有一個Rails 3.2.14應用程序,我試圖用chartkick
和groupdate
gem來生成一些圖表。我已經安裝了這兩個寶石,我試圖在我的Call
模型上從控制檯執行一些測試查詢。Rails groupdate gem pg error
Call.group_by_day(:created_at)
我拋出一個異常,並出現以下錯誤:
Call Load (8.8ms) SELECT "calls".* FROM "calls" WHERE (created_at IS NOT NULL) GROUP BY (DATE_TRUNC('week', (created_at::timestamptz - INTERVAL '6 day' - INTERVAL '0' hour) AT TIME ZONE 'America/Chicago') + INTERVAL '6 day' + INTERVAL '0' hour) AT TIME ZONE 'America/Chicago'
ActiveRecord::StatementInvalid: PG::Error: ERROR: column "calls.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "calls".* FROM "calls" WHERE (created_at IS NOT NULL...
^
: SELECT "calls".* FROM "calls" WHERE (created_at IS NOT NULL) GROUP BY (DATE_TRUNC('week', (created_at::timestamptz - INTERVAL '6 day' - INTERVAL '0' hour) AT TIME ZONE 'America/Chicago') + INTERVAL '6 day' + INTERVAL '0' hour) AT TIME ZONE 'America/Chicago
有什麼我應該做的,使這項工作?是否有某種範圍需要創建才能完成這項工作?我是新來的寶石,所以任何幫助將不勝感激。
協會怎麼樣? – Hamdan 2016-12-14 16:18:00