Method: ActiveRecord::QueryMethods#having
- Defined in:
- lib/active_record/relation/query_methods.rb
#having(opts, *rest) ⇒ Object
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')
604 605 606 |
# File 'lib/active_record/relation/query_methods.rb', line 604 def having(opts, *rest) opts.blank? ? self : spawn.having!(opts, *rest) end |