Получение ошибки:
ActiveRecord::StatementInvalid (PGError: ERROR: argument of HAVING must be type boolean, not type timestamp without time zone
фрагмент кода контроллера:
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
изменен
:having => 'MAX(appointments.start_time)'
до
:having => ['MAX(appointments.start_time) <= ?', @number_days.days.ago]
и теперь ошибка:
ActiveRecord::StatementInvalid (PGError: ERROR: column "clients.id" must appear in the GROUP BY clause or be used in an aggregate function