acts-as-taggable-on 1.0.16 → 1.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/acts_as_taggable_on/acts_as_taggable_on.rb +20 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.17
|
@@ -223,14 +223,32 @@ module ActiveRecord
|
|
223
223
|
|
224
224
|
joins = ["LEFT OUTER JOIN #{Tagging.table_name} ON #{Tag.table_name}.id = #{Tagging.table_name}.tag_id"]
|
225
225
|
joins << sanitize_sql(["AND #{Tagging.table_name}.context = ?",options.delete(:on).to_s]) unless options[:on].nil?
|
226
|
-
|
227
226
|
joins << " INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{Tagging.table_name}.taggable_id"
|
227
|
+
|
228
228
|
unless self.descends_from_active_record?
|
229
229
|
# Current model is STI descendant, so add type checking to the join condition
|
230
230
|
joins << " AND #{table_name}.#{self.inheritance_column} = '#{self.name}'"
|
231
231
|
end
|
232
232
|
|
233
|
-
|
233
|
+
# Based on a proposed patch by donV to ActiveRecord Base
|
234
|
+
# This is needed because merge_joins and construct_join are private in ActiveRecord Base
|
235
|
+
if scope && scope[:joins]
|
236
|
+
case scope[:joins]
|
237
|
+
when Array
|
238
|
+
scope_joins = scope[:joins].flatten
|
239
|
+
strings = scope_joins.select{|j| j.is_a? String}
|
240
|
+
joins << strings.join(' ') + " "
|
241
|
+
symbols = scope_joins - strings
|
242
|
+
join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, symbols, nil)
|
243
|
+
joins << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
|
244
|
+
joins.flatten!
|
245
|
+
when Symbol, Hash
|
246
|
+
join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, scope[:joins], nil)
|
247
|
+
joins << " #{join_dependency.join_associations.collect { |assoc| assoc.association_join }.join} "
|
248
|
+
when String
|
249
|
+
joins << scope[:joins]
|
250
|
+
end
|
251
|
+
end
|
234
252
|
|
235
253
|
at_least = sanitize_sql(['COUNT(*) >= ?', options.delete(:at_least)]) if options[:at_least]
|
236
254
|
at_most = sanitize_sql(['COUNT(*) <= ?', options.delete(:at_most)]) if options[:at_most]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-05 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|