[英]ROR heroku PostGres issue
getting error: 得到错误:
ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type timestamp without time zone
controller code snippet: 控制器代码段:
def inactive
@number_days = params[:days].to_i || 90
@clients = Client.find(:all,
:include => :appointments,
:conditions => ["clients.user_id = ? AND appointments.start_time <= ?", current_user.id, @number_days.days.ago],
:group => 'client_id',
:having => 'MAX(appointments.start_time)'
)
end
changed 变
:having => 'MAX(appointments.start_time)'
to 至
:having => ['MAX(appointments.start_time) <= ?', @number_days.days.ago]
and now error is: 现在的错误是:
ActiveRecord::StatementInvalid (PGError: ERROR: column "clients.id" must appear in the GROUP BY clause or be used in an aggregate function
The :having
clause requires a SQL snippet that evaluates to a boolean. :having
子句需要一个评估为布尔值的SQL片段。 MAX(appointments.start_time)
evaluates to a timestamp MAX(appointments.start_time)
计算为时间戳
change:group =>'client_id'to:group =>'table_name.client_id'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.