acts-as-taggable-on-for-domains 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -1,28 +1,26 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts-as-taggable-on-for-domains}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Bleigh", "Josh N. Abbott"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-20}
|
13
13
|
s.description = %q{Same as ActsAsTaggableOn but tagging happens within the context of a domain id. This means an object could be tagged with something for one domain, but the same object, in the context of a different domain id, could have completely different taggings.}
|
14
14
|
s.email = %q{joshnabbott@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
"README"
|
18
|
-
"README.rdoc"
|
17
|
+
"README"
|
19
18
|
]
|
20
19
|
s.files = [
|
21
20
|
".document",
|
22
21
|
".gitignore",
|
23
22
|
"LICENSE",
|
24
23
|
"README",
|
25
|
-
"README.rdoc",
|
26
24
|
"Rakefile",
|
27
25
|
"VERSION",
|
28
26
|
"acts-as-taggable-on-for-domains.gemspec",
|
@@ -77,3 +75,4 @@ Gem::Specification.new do |s|
|
|
77
75
|
else
|
78
76
|
end
|
79
77
|
end
|
78
|
+
|
@@ -143,29 +143,31 @@ module ActiveRecord
|
|
143
143
|
if options.delete(:exclude)
|
144
144
|
tags_conditions = tags.map { |t| sanitize_sql(["#{Tag.table_name}.name LIKE ?", t]) }.join(" OR ")
|
145
145
|
conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{Tagging.table_name}.taggable_id FROM #{Tagging.table_name} JOIN #{Tag.table_name} ON #{Tagging.table_name}.tag_id = #{Tag.table_name}.id AND (#{tags_conditions}) WHERE #{Tagging.table_name}.taggable_type = #{quote_value(base_class.name)})"
|
146
|
-
|
147
|
-
else
|
146
|
+
|
147
|
+
else
|
148
148
|
tags.each do |tag|
|
149
149
|
safe_tag = tag.gsub(/[^a-zA-Z0-9]/, '')
|
150
150
|
prefix = "#{safe_tag}_#{rand(1024)}"
|
151
|
-
|
151
|
+
|
152
152
|
taggings_alias = "#{table_name}_taggings_#{prefix}"
|
153
153
|
tags_alias = "#{table_name}_tags_#{prefix}"
|
154
|
-
|
154
|
+
|
155
155
|
tagging_join = "JOIN #{Tagging.table_name} #{taggings_alias}" +
|
156
156
|
" ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
|
157
157
|
" AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}"
|
158
158
|
tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context
|
159
|
-
|
159
|
+
|
160
|
+
tagging_join << " AND #{taggings_alias}.domain_id = #{Domain.current_domain_id}"
|
161
|
+
|
160
162
|
tag_join = "JOIN #{Tag.table_name} #{tags_alias}" +
|
161
163
|
" ON #{tags_alias}.id = #{taggings_alias}.tag_id" +
|
162
164
|
" AND " + sanitize_sql(["#{tags_alias}.name like ?", tag])
|
163
|
-
|
165
|
+
|
164
166
|
joins << tagging_join
|
165
167
|
joins << tag_join
|
166
|
-
end
|
168
|
+
end
|
167
169
|
end
|
168
|
-
|
170
|
+
|
169
171
|
taggings_alias, tags_alias = "#{table_name}_taggings_group", "#{table_name}_tags_group"
|
170
172
|
|
171
173
|
if options.delete(:match_all)
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module ActsAsTaggableOnScopedByDomain
|
2
|
-
|
3
|
-
RAILS_DEFAULT_LOGGER.info "** Extended acts_as_taggable_on for domain scoping."
|
2
|
+
RAILS_DEFAULT_LOGGER.info "** Extended acts_as_taggable_on for domain scoping."
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
ActiveRecord::Acts::TaggableOn::SingletonMethods.module_eval do
|
5
|
+
# Had to not use this method of scoping by domain because there's no way here to use the same
|
6
|
+
# table alias as what's being used for the tagging.
|
7
|
+
#
|
8
|
+
# def find_options_for_find_tagged_with_with_domain_id(tags, options = {})
|
9
|
+
# options = options.reverse_merge!(:conditions => ["domain_id = ?", Domain.current_domain_id])
|
10
|
+
# find_options_for_find_tagged_with_without_domain_id(tags, options)
|
11
|
+
# end
|
12
|
+
# alias_method_chain :find_options_for_find_tagged_with, :domain_id
|
10
13
|
|
11
14
|
def find_options_for_tag_counts_with_domain_id(options = {})
|
12
|
-
options = options.reverse_merge!(:conditions => "domain_id = #{Domain.current_domain_id}")
|
15
|
+
options = options.reverse_merge!(:conditions => "`taggings`.domain_id = #{Domain.current_domain_id}")
|
13
16
|
find_options_for_tag_counts_without_domain_id(options)
|
14
17
|
end
|
15
18
|
alias_method_chain :find_options_for_tag_counts, :domain_id
|
@@ -3,6 +3,10 @@ class Tag < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
validates_presence_of :name
|
5
5
|
validates_uniqueness_of :name
|
6
|
+
|
7
|
+
# Find all tags for a specific context.
|
8
|
+
# USAGE: Tag.for_context('collection_tags') #=> Would return an array of unique tags used in the specified context
|
9
|
+
named_scope :for_context, lambda { |context| { :select => 'DISTINCT `tags`.`id`, `tags`.`name`', :joins => 'INNER JOIN taggings ON `taggings`.`tag_id` = `tags`.`id`', :conditions => ['`taggings`.`context` = ?', context] } }
|
6
10
|
|
7
11
|
# LIKE is used for cross-database case-insensitivity
|
8
12
|
def self.find_or_create_with_like_by_name(name)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-on-for-domains
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-20 00:00:00 -08:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -23,13 +23,11 @@ extensions: []
|
|
23
23
|
extra_rdoc_files:
|
24
24
|
- LICENSE
|
25
25
|
- README
|
26
|
-
- README.rdoc
|
27
26
|
files:
|
28
27
|
- .document
|
29
28
|
- .gitignore
|
30
29
|
- LICENSE
|
31
30
|
- README
|
32
|
-
- README.rdoc
|
33
31
|
- Rakefile
|
34
32
|
- VERSION
|
35
33
|
- acts-as-taggable-on-for-domains.gemspec
|
data/README.rdoc
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
= acts-as-taggable-on-for-domains
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Note on Patches/Pull Requests
|
6
|
-
|
7
|
-
* Fork the project.
|
8
|
-
* Make your feature addition or bug fix.
|
9
|
-
* Add tests for it. This is important so I don't break it in a
|
10
|
-
future version unintentionally.
|
11
|
-
* Commit, do not mess with rakefile, version, or history.
|
12
|
-
(if you want to have your own version, that is fine but
|
13
|
-
bump version in a commit by itself I can ignore when I pull)
|
14
|
-
* Send me a pull request. Bonus points for topic branches.
|
15
|
-
|
16
|
-
== Copyright
|
17
|
-
|
18
|
-
Copyright (c) 2009 Josh N. Abbott. See LICENSE for details.
|