I have this ActiveRecord amount:
@websites = current_user.records.sum(:minutes, :group =>'website', :conditions => "website IS NOT NULL")
I would like to limit it to the top 10 minutes. Can someone tell me the syntax for this?
Thanks in advance.
You can :orderover the summarized column, and then :limitup to 10 rows:
:order
:limit
@websites = current_user.records.sum(:minutes, :group => 'website', :conditions => 'website IS NOT NULL', :order => 'SUM(minutes) DESC', :limit => 10)
Just add :limitfor example:
current_user.records.sum(:minutes, :group => '', :conditions => '', :limit => num)
Source: https://habr.com/ru/post/1776311/More articles:Android: How to program EAP wifi configuration programmatically? - androidDjango and thread security - pythonSpring AOP with anonymous inner classes - javaRMISecurityManager vs SecurityManager - javaAndroid programming error - androidfgetc (): Read and save a string of unknown length - cWhat is code injection in .net (as a programming skill)? - .netHow are instances resolved when child containers are used? - castle-windsorHow to get the full file path in Zend - phpWhat is the rationale for Assignment in State alerts in the Zend Studio IDE? - phpAll Articles