acts-as-taggable-on 3.1.1 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +9 -7
- data/Appraisals +13 -8
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -2
- data/README.md +23 -13
- data/Rakefile +5 -17
- data/UPGRADING.md +6 -0
- data/acts-as-taggable-on.gemspec +13 -13
- data/db/migrate/1_acts_as_taggable_on_migration.rb +3 -3
- data/db/migrate/2_add_missing_unique_indices.rb +3 -5
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +1 -1
- data/gemfiles/activerecord_3.2.gemfile +15 -0
- data/gemfiles/activerecord_4.0.gemfile +15 -0
- data/gemfiles/activerecord_4.1.gemfile +15 -0
- data/gemfiles/activerecord_edge.gemfile +16 -0
- data/lib/acts-as-taggable-on.rb +23 -21
- data/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb +1 -4
- data/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb +29 -20
- data/lib/acts_as_taggable_on/acts_as_taggable_on/compatibility.rb +11 -10
- data/lib/acts_as_taggable_on/acts_as_taggable_on/core.rb +98 -80
- data/lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb +5 -12
- data/lib/acts_as_taggable_on/acts_as_taggable_on/related.rb +7 -7
- data/lib/acts_as_taggable_on/engine.rb +0 -1
- data/lib/acts_as_taggable_on/tag.rb +24 -19
- data/lib/acts_as_taggable_on/tag_list.rb +95 -21
- data/lib/acts_as_taggable_on/taggable.rb +28 -30
- data/lib/acts_as_taggable_on/tagger.rb +30 -18
- data/lib/acts_as_taggable_on/tagging.rb +7 -8
- data/lib/acts_as_taggable_on/tags_helper.rb +1 -1
- data/lib/acts_as_taggable_on/utils.rb +25 -3
- data/lib/acts_as_taggable_on/version.rb +1 -1
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +133 -138
- data/spec/acts_as_taggable_on/acts_as_tagger_spec.rb +55 -58
- data/spec/acts_as_taggable_on/caching_spec.rb +34 -35
- data/spec/acts_as_taggable_on/related_spec.rb +59 -113
- data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +118 -95
- data/spec/acts_as_taggable_on/tag_list_spec.rb +89 -57
- data/spec/acts_as_taggable_on/tag_spec.rb +125 -114
- data/spec/acts_as_taggable_on/taggable_spec.rb +538 -352
- data/spec/acts_as_taggable_on/tagger_spec.rb +81 -78
- data/spec/acts_as_taggable_on/tagging_spec.rb +13 -14
- data/spec/acts_as_taggable_on/tags_helper_spec.rb +25 -25
- data/spec/acts_as_taggable_on/utils_spec.rb +9 -9
- data/spec/internal/app/models/altered_inheriting_taggable_model.rb +3 -0
- data/spec/internal/app/models/cached_model.rb +3 -0
- data/spec/internal/app/models/cached_model_with_array.rb +5 -0
- data/spec/internal/app/models/company.rb +15 -0
- data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/market.rb +2 -0
- data/spec/{models.rb → internal/app/models/models.rb} +34 -2
- data/spec/internal/app/models/non_standard_id_taggable_model.rb +8 -0
- data/spec/internal/app/models/ordered_taggable_model.rb +4 -0
- data/spec/internal/app/models/other_cached_model.rb +3 -0
- data/spec/internal/app/models/other_taggable_model.rb +4 -0
- data/spec/internal/app/models/student.rb +2 -0
- data/spec/internal/app/models/taggable_model.rb +13 -0
- data/spec/internal/app/models/untaggable_model.rb +3 -0
- data/spec/internal/app/models/user.rb +3 -0
- data/spec/{database.yml.sample → internal/config/database.yml.sample} +2 -2
- data/spec/internal/db/schema.rb +97 -0
- data/spec/schema.rb +11 -0
- data/spec/spec_helper.rb +9 -62
- data/spec/support/array.rb +9 -0
- data/spec/support/database.rb +42 -0
- data/spec/support/database_cleaner.rb +17 -0
- metadata +101 -37
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.0.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_edge.gemfile +0 -7
@@ -1,137 +1,140 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe 'Tagger' do
|
4
4
|
before(:each) do
|
5
|
-
clean_database!
|
6
5
|
@user = User.create
|
7
|
-
@taggable = TaggableModel.create(:
|
6
|
+
@taggable = TaggableModel.create(name: 'Bob Jones')
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
|
10
|
+
|
11
|
+
it 'should have taggings' do
|
12
|
+
@user.tag(@taggable, with: 'ruby,scheme', on: :tags)
|
13
|
+
expect(@user.owned_taggings.size).to eq(2)
|
13
14
|
end
|
14
15
|
|
15
|
-
it
|
16
|
-
@user.tag(@taggable, :
|
17
|
-
@user.owned_tags.size
|
16
|
+
it 'should have tags' do
|
17
|
+
@user.tag(@taggable, with: 'ruby,scheme', on: :tags)
|
18
|
+
expect(@user.owned_tags.size).to eq(2)
|
18
19
|
end
|
19
20
|
|
20
|
-
it
|
21
|
-
@taggable2 = TaggableModel.create(:
|
22
|
-
@taggable3 = TaggableModel.create(:
|
21
|
+
it 'should scope objects returned by tagged_with by owners' do
|
22
|
+
@taggable2 = TaggableModel.create(name: 'Jim Jones')
|
23
|
+
@taggable3 = TaggableModel.create(name: 'Jane Doe')
|
23
24
|
|
24
25
|
@user2 = User.new
|
25
|
-
@user.tag(@taggable, :
|
26
|
-
@user2.tag(@taggable2, :
|
27
|
-
@user2.tag(@taggable3, :
|
26
|
+
@user.tag(@taggable, with: 'ruby, scheme', on: :tags)
|
27
|
+
@user2.tag(@taggable2, with: 'ruby, scheme', on: :tags)
|
28
|
+
@user2.tag(@taggable3, with: 'ruby, scheme', on: :tags)
|
28
29
|
|
29
|
-
TaggableModel.tagged_with(%w(ruby scheme), :
|
30
|
-
TaggableModel.tagged_with(%w(ruby scheme), :
|
30
|
+
expect(TaggableModel.tagged_with(%w(ruby scheme), owned_by: @user).count).to eq(1)
|
31
|
+
expect(TaggableModel.tagged_with(%w(ruby scheme), owned_by: @user2).count).to eq(2)
|
31
32
|
end
|
32
33
|
|
33
|
-
it
|
34
|
+
it 'only returns objects tagged by owned_by when any is true' do
|
34
35
|
@user2 = User.new
|
35
|
-
@taggable2 = TaggableModel.create(:
|
36
|
-
@taggable3 = TaggableModel.create(:
|
36
|
+
@taggable2 = TaggableModel.create(name: 'Jim Jones')
|
37
|
+
@taggable3 = TaggableModel.create(name: 'Jane Doe')
|
38
|
+
|
39
|
+
@user.tag(@taggable, with: 'ruby', on: :tags)
|
40
|
+
@user.tag(@taggable2, with: 'java', on: :tags)
|
41
|
+
@user2.tag(@taggable3, with: 'ruby', on: :tags)
|
37
42
|
|
38
|
-
|
39
|
-
|
40
|
-
|
43
|
+
tags = TaggableModel.tagged_with(%w(ruby java), owned_by: @user, any: true)
|
44
|
+
expect(tags).to include(@taggable, @taggable2)
|
45
|
+
expect(tags.size).to eq(2)
|
41
46
|
|
42
|
-
tags = TaggableModel.tagged_with(%w(ruby java), :owned_by => @user, :any => true)
|
43
|
-
tags.should match_array [@taggable, @taggable2]
|
44
47
|
end
|
45
48
|
|
46
|
-
it
|
49
|
+
it 'only returns objects tagged by owned_by when exclude is true' do
|
47
50
|
@user2 = User.new
|
48
|
-
@taggable2 = TaggableModel.create(:
|
49
|
-
@taggable3 = TaggableModel.create(:
|
51
|
+
@taggable2 = TaggableModel.create(name: 'Jim Jones')
|
52
|
+
@taggable3 = TaggableModel.create(name: 'Jane Doe')
|
50
53
|
|
51
|
-
@user.tag(@taggable, :
|
52
|
-
@user.tag(@taggable2, :
|
53
|
-
@user2.tag(@taggable3, :
|
54
|
+
@user.tag(@taggable, with: 'ruby', on: :tags)
|
55
|
+
@user.tag(@taggable2, with: 'java', on: :tags)
|
56
|
+
@user2.tag(@taggable3, with: 'java', on: :tags)
|
54
57
|
|
55
|
-
tags = TaggableModel.tagged_with(%w(ruby), :
|
56
|
-
tags.
|
58
|
+
tags = TaggableModel.tagged_with(%w(ruby), owned_by: @user, exclude: true)
|
59
|
+
expect(tags).to eq([@taggable2])
|
57
60
|
end
|
58
61
|
|
59
|
-
it
|
62
|
+
it 'should not overlap tags from different taggers' do
|
60
63
|
@user2 = User.new
|
61
|
-
|
62
|
-
@user.tag(@taggable, :
|
63
|
-
@user2.tag(@taggable, :
|
64
|
-
}.
|
64
|
+
expect(-> {
|
65
|
+
@user.tag(@taggable, with: 'ruby, scheme', on: :tags)
|
66
|
+
@user2.tag(@taggable, with: 'java, python, lisp, ruby', on: :tags)
|
67
|
+
}).to change(ActsAsTaggableOn::Tagging, :count).by(6)
|
65
68
|
|
66
69
|
[@user, @user2, @taggable].each(&:reload)
|
67
70
|
|
68
|
-
@user.owned_tags.map(&:name).sort.
|
69
|
-
@user2.owned_tags.map(&:name).sort.
|
71
|
+
expect(@user.owned_tags.map(&:name).sort).to eq(%w(ruby scheme).sort)
|
72
|
+
expect(@user2.owned_tags.map(&:name).sort).to eq(%w(java python lisp ruby).sort)
|
70
73
|
|
71
|
-
@taggable.tags_from(@user).sort.
|
72
|
-
@taggable.tags_from(@user2).sort.
|
74
|
+
expect(@taggable.tags_from(@user).sort).to eq(%w(ruby scheme).sort)
|
75
|
+
expect(@taggable.tags_from(@user2).sort).to eq(%w(java lisp python ruby).sort)
|
73
76
|
|
74
|
-
@taggable.all_tags_list.sort.
|
75
|
-
@taggable.all_tags_on(:tags).size.
|
77
|
+
expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme java python lisp).sort)
|
78
|
+
expect(@taggable.all_tags_on(:tags).size).to eq(5)
|
76
79
|
end
|
77
80
|
|
78
|
-
it
|
81
|
+
it 'should not lose tags from different taggers' do
|
79
82
|
@user2 = User.create
|
80
|
-
@user2.tag(@taggable, :
|
81
|
-
@user.tag(@taggable, :
|
83
|
+
@user2.tag(@taggable, with: 'java, python, lisp, ruby', on: :tags)
|
84
|
+
@user.tag(@taggable, with: 'ruby, scheme', on: :tags)
|
82
85
|
|
83
|
-
|
84
|
-
@user2.tag(@taggable, :
|
85
|
-
}.
|
86
|
+
expect(-> {
|
87
|
+
@user2.tag(@taggable, with: 'java, python, lisp', on: :tags)
|
88
|
+
}).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
|
86
89
|
|
87
90
|
[@user, @user2, @taggable].each(&:reload)
|
88
91
|
|
89
|
-
@taggable.tags_from(@user).sort.
|
90
|
-
@taggable.tags_from(@user2).sort.
|
92
|
+
expect(@taggable.tags_from(@user).sort).to eq(%w(ruby scheme).sort)
|
93
|
+
expect(@taggable.tags_from(@user2).sort).to eq(%w(java python lisp).sort)
|
91
94
|
|
92
|
-
@taggable.all_tags_list.sort.
|
93
|
-
@taggable.all_tags_on(:tags).length.
|
95
|
+
expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme java python lisp).sort)
|
96
|
+
expect(@taggable.all_tags_on(:tags).length).to eq(5)
|
94
97
|
end
|
95
98
|
|
96
|
-
it
|
99
|
+
it 'should not lose tags' do
|
97
100
|
@user2 = User.create
|
98
101
|
|
99
|
-
@user.tag(@taggable, :
|
100
|
-
@user2.tag(@taggable, :
|
102
|
+
@user.tag(@taggable, with: 'awesome', on: :tags)
|
103
|
+
@user2.tag(@taggable, with: 'awesome, epic', on: :tags)
|
101
104
|
|
102
|
-
|
103
|
-
@user2.tag(@taggable, :
|
104
|
-
}.
|
105
|
+
expect(-> {
|
106
|
+
@user2.tag(@taggable, with: 'epic', on: :tags)
|
107
|
+
}).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
|
105
108
|
|
106
109
|
@taggable.reload
|
107
|
-
@taggable.all_tags_list.
|
108
|
-
@taggable.all_tags_list.
|
110
|
+
expect(@taggable.all_tags_list).to include('awesome')
|
111
|
+
expect(@taggable.all_tags_list).to include('epic')
|
109
112
|
end
|
110
113
|
|
111
|
-
it
|
112
|
-
@taggable.update_attributes(:
|
113
|
-
@user.tag(@taggable, :
|
114
|
+
it 'should not lose tags' do
|
115
|
+
@taggable.update_attributes(tag_list: 'ruby')
|
116
|
+
@user.tag(@taggable, with: 'ruby, scheme', on: :tags)
|
114
117
|
|
115
118
|
[@taggable, @user].each(&:reload)
|
116
|
-
@taggable.tag_list.
|
117
|
-
@taggable.all_tags_list.sort.
|
119
|
+
expect(@taggable.tag_list).to eq(%w(ruby))
|
120
|
+
expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme).sort)
|
118
121
|
|
119
|
-
|
120
|
-
@taggable.update_attributes(:
|
121
|
-
}.
|
122
|
+
expect(-> {
|
123
|
+
@taggable.update_attributes(tag_list: '')
|
124
|
+
}).to change(ActsAsTaggableOn::Tagging, :count).by(-1)
|
122
125
|
|
123
|
-
@taggable.tag_list.
|
124
|
-
@taggable.all_tags_list.sort.
|
126
|
+
expect(@taggable.tag_list).to be_empty
|
127
|
+
expect(@taggable.all_tags_list.sort).to eq(%w(ruby scheme).sort)
|
125
128
|
end
|
126
129
|
|
127
|
-
it
|
128
|
-
@user.is_tagger
|
130
|
+
it 'is tagger' do
|
131
|
+
expect(@user.is_tagger?).to be_truthy
|
129
132
|
end
|
130
133
|
|
131
|
-
it
|
132
|
-
|
133
|
-
@user.tag(@taggable, :
|
134
|
-
}.
|
134
|
+
it 'should skip save if skip_save is passed as option' do
|
135
|
+
expect(-> {
|
136
|
+
@user.tag(@taggable, with: 'epic', on: :tags, skip_save: true)
|
137
|
+
}).to_not change(ActsAsTaggableOn::Tagging, :count)
|
135
138
|
end
|
136
139
|
|
137
140
|
end
|
@@ -2,27 +2,26 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActsAsTaggableOn::Tagging do
|
4
4
|
before(:each) do
|
5
|
-
clean_database!
|
6
5
|
@tagging = ActsAsTaggableOn::Tagging.new
|
7
6
|
end
|
8
7
|
|
9
|
-
it
|
10
|
-
@tagging.taggable = TaggableModel.create(:
|
11
|
-
@tagging.tag = ActsAsTaggableOn::Tag.new(:
|
12
|
-
@tagging.context =
|
8
|
+
it 'should not be valid with a invalid tag' do
|
9
|
+
@tagging.taggable = TaggableModel.create(name: 'Bob Jones')
|
10
|
+
@tagging.tag = ActsAsTaggableOn::Tag.new(name: '')
|
11
|
+
@tagging.context = 'tags'
|
13
12
|
|
14
|
-
@tagging.
|
15
|
-
|
16
|
-
@tagging.errors[:tag_id].
|
13
|
+
expect(@tagging).to_not be_valid
|
14
|
+
|
15
|
+
expect(@tagging.errors[:tag_id]).to eq(['can\'t be blank'])
|
17
16
|
end
|
18
17
|
|
19
|
-
it
|
20
|
-
@taggable = TaggableModel.create(:
|
21
|
-
@tag = ActsAsTaggableOn::Tag.create(:
|
18
|
+
it 'should not create duplicate taggings' do
|
19
|
+
@taggable = TaggableModel.create(name: 'Bob Jones')
|
20
|
+
@tag = ActsAsTaggableOn::Tag.create(name: 'awesome')
|
22
21
|
|
23
|
-
|
24
|
-
2.times { ActsAsTaggableOn::Tagging.create(:
|
25
|
-
}.
|
22
|
+
expect(-> {
|
23
|
+
2.times { ActsAsTaggableOn::Tagging.create(taggable: @taggable, tag: @tag, context: 'tags') }
|
24
|
+
}).to change(ActsAsTaggableOn::Tagging, :count).by(1)
|
26
25
|
end
|
27
26
|
|
28
27
|
end
|
@@ -2,43 +2,43 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActsAsTaggableOn::TagsHelper do
|
4
4
|
before(:each) do
|
5
|
-
|
6
|
-
|
7
|
-
@
|
8
|
-
|
9
|
-
@
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end.new
|
5
|
+
@bob = TaggableModel.create(name: 'Bob Jones', language_list: 'ruby, php')
|
6
|
+
@tom = TaggableModel.create(name: 'Tom Marley', language_list: 'ruby, java')
|
7
|
+
@eve = TaggableModel.create(name: 'Eve Nodd', language_list: 'ruby, c++')
|
8
|
+
|
9
|
+
@helper =
|
10
|
+
class Helper
|
11
|
+
include ActsAsTaggableOn::TagsHelper
|
12
|
+
end.new
|
14
13
|
end
|
15
14
|
|
16
|
-
it "should yield the proper css classes" do
|
17
|
-
tags = { }
|
18
15
|
|
19
|
-
|
16
|
+
it 'should yield the proper css classes' do
|
17
|
+
tags = {}
|
18
|
+
|
19
|
+
@helper.tag_cloud(TaggableModel.tag_counts_on(:languages), %w(sucky awesome)) do |tag, css_class|
|
20
20
|
tags[tag.name] = css_class
|
21
21
|
end
|
22
22
|
|
23
|
-
tags[
|
24
|
-
tags[
|
25
|
-
tags[
|
26
|
-
tags[
|
23
|
+
expect(tags['ruby']).to eq('awesome')
|
24
|
+
expect(tags['java']).to eq('sucky')
|
25
|
+
expect(tags['c++']).to eq('sucky')
|
26
|
+
expect(tags['php']).to eq('sucky')
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
it 'should handle tags with zero counts (build for empty)' do
|
30
|
+
ActsAsTaggableOn::Tag.create(name: 'php')
|
31
|
+
ActsAsTaggableOn::Tag.create(name: 'java')
|
32
|
+
ActsAsTaggableOn::Tag.create(name: 'c++')
|
33
33
|
|
34
|
-
tags = {
|
34
|
+
tags = {}
|
35
35
|
|
36
|
-
@helper.tag_cloud(ActsAsTaggableOn::Tag.all,
|
36
|
+
@helper.tag_cloud(ActsAsTaggableOn::Tag.all, %w(sucky awesome)) do |tag, css_class|
|
37
37
|
tags[tag.name] = css_class
|
38
38
|
end
|
39
39
|
|
40
|
-
tags[
|
41
|
-
tags[
|
42
|
-
tags[
|
40
|
+
expect(tags['java']).to eq('sucky')
|
41
|
+
expect(tags['c++']).to eq('sucky')
|
42
|
+
expect(tags['php']).to eq('sucky')
|
43
43
|
end
|
44
44
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe ActsAsTaggableOn::Utils do
|
4
|
-
describe
|
4
|
+
describe 'like_operator' do
|
5
5
|
before(:each) do
|
6
|
-
clean_database!
|
7
6
|
TaggableModel.acts_as_taggable_on(:tags, :languages, :skills, :needs, :offerings)
|
8
|
-
@taggable = TaggableModel.new(:
|
7
|
+
@taggable = TaggableModel.new(name: 'Bob Jones')
|
9
8
|
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
TaggableModel.
|
10
|
+
|
11
|
+
it 'should return \'ILIKE\' when the adapter is PostgreSQL' do
|
12
|
+
allow(TaggableModel.connection).to receive(:adapter_name) { 'PostgreSQL' }
|
13
|
+
expect(TaggableModel.send(:like_operator)).to eq('ILIKE')
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
TaggableModel.connection.
|
18
|
-
TaggableModel.send(:like_operator).
|
16
|
+
it 'should return \'LIKE\' when the adapter is not PostgreSQL' do
|
17
|
+
allow(TaggableModel.connection).to receive(:adapter_name) { 'MySQL' }
|
18
|
+
expect(TaggableModel.send(:like_operator)).to eq('LIKE')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Company < ActiveRecord::Base
|
2
|
+
acts_as_taggable_on :locations, :markets
|
3
|
+
|
4
|
+
has_many :markets, :through => :market_taggings, :source => :tag
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def find_or_create_tags_from_list_with_context(tag_list, context)
|
9
|
+
if context.to_sym == :markets
|
10
|
+
Market.find_or_create_all_with_like_by_name(tag_list)
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -6,7 +6,8 @@ class TaggableModel < ActiveRecord::Base
|
|
6
6
|
has_many :untaggable_models
|
7
7
|
|
8
8
|
attr_reader :tag_list_submethod_called
|
9
|
-
|
9
|
+
|
10
|
+
def tag_list=(v)
|
10
11
|
@tag_list_submethod_called = true
|
11
12
|
super
|
12
13
|
end
|
@@ -32,6 +33,25 @@ class AlteredInheritingTaggableModel < TaggableModel
|
|
32
33
|
acts_as_taggable_on :parts
|
33
34
|
end
|
34
35
|
|
36
|
+
class Market < ActsAsTaggableOn::Tag
|
37
|
+
end
|
38
|
+
|
39
|
+
class Company < ActiveRecord::Base
|
40
|
+
acts_as_taggable_on :locations, :markets
|
41
|
+
|
42
|
+
has_many :markets, :through => :market_taggings, :source => :tag
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def find_or_create_tags_from_list_with_context(tag_list, context)
|
47
|
+
if context.to_sym == :markets
|
48
|
+
Market.find_or_create_all_with_like_by_name(tag_list)
|
49
|
+
else
|
50
|
+
super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
35
55
|
class User < ActiveRecord::Base
|
36
56
|
acts_as_tagger
|
37
57
|
end
|
@@ -44,7 +64,7 @@ class UntaggableModel < ActiveRecord::Base
|
|
44
64
|
end
|
45
65
|
|
46
66
|
class NonStandardIdTaggableModel < ActiveRecord::Base
|
47
|
-
primary_key =
|
67
|
+
self.primary_key = :an_id
|
48
68
|
acts_as_taggable
|
49
69
|
acts_as_taggable_on :languages
|
50
70
|
acts_as_taggable_on :skills
|
@@ -56,3 +76,15 @@ class OrderedTaggableModel < ActiveRecord::Base
|
|
56
76
|
acts_as_ordered_taggable
|
57
77
|
acts_as_ordered_taggable_on :colours
|
58
78
|
end
|
79
|
+
|
80
|
+
if ActsAsTaggableOn::Utils.using_postgresql?
|
81
|
+
class CachedModelWithArray < ActiveRecord::Base
|
82
|
+
acts_as_taggable
|
83
|
+
end
|
84
|
+
if ActsAsTaggableOn::Utils.postgresql_support_json?
|
85
|
+
class TaggableModelWithJson < ActiveRecord::Base
|
86
|
+
acts_as_taggable
|
87
|
+
acts_as_taggable_on :skills
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|