bborn-acts_as_taggable_on_steroids 2.0.beta2 → 2.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_taggable_on_steroids.gemspec +1 -1
- data/lib/tag.rb +7 -3
- metadata +1 -1
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "bborn-acts_as_taggable_on_steroids"
|
3
|
-
s.version = "2.0.
|
3
|
+
s.version = "2.0.beta3"
|
4
4
|
s.date = "2011-02-07"
|
5
5
|
s.summary = "Rails 3 plugin that is based on acts_as_taggable by jviney that is based on acts_as_taggable by DHH."
|
6
6
|
s.email = "ysbaddaden@gmail.com"
|
data/lib/tag.rb
CHANGED
@@ -40,9 +40,9 @@ class Tag < ActiveRecord::Base
|
|
40
40
|
# - +:order+
|
41
41
|
#
|
42
42
|
def counts(options = {})
|
43
|
-
options.assert_valid_keys :start_at, :end_at, :at_least, :at_most, :conditions, :limit, :order
|
43
|
+
options.assert_valid_keys :start_at, :end_at, :at_least, :at_most, :conditions, :limit, :order, :joins
|
44
44
|
|
45
|
-
tags = joins(:taggings)
|
45
|
+
tags = joins(:taggings)
|
46
46
|
tags = tags.having(['count >= ?', options[:at_least]]) if options[:at_least]
|
47
47
|
tags = tags.having(['count <= ?', options[:at_most]]) if options[:at_most]
|
48
48
|
tags = tags.where("#{Tagging.quoted_table_name}.created_at >= ?", options[:start_at]) if options[:start_at]
|
@@ -53,7 +53,11 @@ class Tag < ActiveRecord::Base
|
|
53
53
|
tags = tags.limit(options[:limit]) if options[:limit]
|
54
54
|
tags = tags.order(options[:order]) if options[:order]
|
55
55
|
|
56
|
-
|
56
|
+
if joins = options.delete(:joins)
|
57
|
+
tags = tags.joins(joins)
|
58
|
+
end
|
59
|
+
|
60
|
+
tags.select("#{quoted_table_name}.id, #{quoted_table_name}.name, COUNT(#{quoted_table_name}.id) AS count").group('tags.id, tags.name')
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|