method

having

rails latest stable - Class: ActiveRecord::QueryMethods
having(opts, *rest)
public

Allows to specify a HAVING clause. Note that you can’t use HAVING without also specifying a GROUP clause.

Order.having('SUM(price) > 30').group('user_id')