Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added limit method

  • Loading branch information...
commit 1066ff7341fd2793192adc959388a4563d63f7d3 1 parent d0cb558
Lee Martin authored
Showing with 1 addition and 0 deletions.
  1. +1 −0  lib/acts_as_voteable.rb
1  lib/acts_as_voteable.rb
View
@@ -53,6 +53,7 @@ def plusminus_tally(*args)
t = t.where("joined_#{Vote.table_name}.voteable_type = '#{self.name}'")
t = t.group("joined_#{Vote.table_name}.voteable_id, joined_#{Vote.table_name}.vote_total, #{column_names_for_tally}")
+ t = t.limit(options[:limit]) if options[:limit]
t = t.where("joined_#{Vote.table_name}.created_at >= ?", options[:start_at]) if options[:start_at]
t = t.where("joined_#{Vote.table_name}.created_at <= ?", options[:end_at]) if options[:end_at]
t = options[:ascending] ? t.order("joined_#{Vote.table_name}.vote_total") : t.order("joined_#{Vote.table_name}.vote_total DESC")
Please sign in to comment.
Something went wrong with that request. Please try again.