acts-as-taggable-on 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -11
- data/Appraisals +7 -13
- data/CHANGELOG.md +82 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +1 -1
- data/README.md +42 -10
- data/acts-as-taggable-on.gemspec +2 -2
- data/db/migrate/1_acts_as_taggable_on_migration.rb +6 -1
- data/db/migrate/2_add_missing_unique_indices.rb +6 -1
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +6 -1
- data/db/migrate/4_add_missing_taggable_index.rb +6 -1
- data/db/migrate/5_change_collation_for_tag_names.rb +6 -1
- data/db/migrate/6_add_missing_indexes_on_taggings.rb +22 -0
- data/gemfiles/activerecord_4.2.gemfile +3 -3
- data/gemfiles/activerecord_5.0.gemfile +3 -3
- data/gemfiles/{activerecord_4.0.gemfile → activerecord_5.1.gemfile} +3 -4
- data/lib/acts_as_taggable_on/tag.rb +10 -7
- data/lib/acts_as_taggable_on/tag_list.rb +1 -0
- data/lib/acts_as_taggable_on/taggable/core.rb +10 -157
- data/lib/acts_as_taggable_on/taggable/ownership.rb +16 -5
- data/lib/acts_as_taggable_on/taggable/tagged_with_query.rb +16 -0
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/all_tags_query.rb +113 -0
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +75 -0
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/exclude_tags_query.rb +82 -0
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb +61 -0
- data/lib/acts_as_taggable_on/tagger.rb +2 -2
- data/lib/acts_as_taggable_on/tagging.rb +3 -2
- data/lib/acts_as_taggable_on/version.rb +1 -1
- data/spec/acts_as_taggable_on/caching_spec.rb +18 -0
- data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +16 -1
- data/spec/acts_as_taggable_on/taggable_spec.rb +1 -1
- data/spec/internal/db/schema.rb +3 -0
- metadata +13 -9
- data/db/migrate/6_add_missing_indexes.rb +0 -12
- data/gemfiles/activerecord_4.1.gemfile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f768ffeb2be31c4e8e131a9b89f796a325aba09f
|
4
|
+
data.tar.gz: d4528a4f594547d31f508300b8188b17fe507295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4246008aa86bb98b30fcb23787e5ddc94af40d8b677701a202ea6db8be2fe30cbab2117bc8b4eb2e2803f02605e392d5bd271ce77155a45d631f9ae6a3f83451
|
7
|
+
data.tar.gz: 6df3714193f6004ff5d69e4bd54f54b866804dcfcb6b6d08721302c22f7da442005b19200a43628b0e5e734dcbf3a5e892435fcda2652c24ea62635c3bff5d4b
|
data/.travis.yml
CHANGED
@@ -2,10 +2,9 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
|
4
4
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.0.0
|
5
|
+
- 2.4.1
|
6
|
+
- 2.3.3
|
7
|
+
- 2.2.7
|
9
8
|
|
10
9
|
env:
|
11
10
|
- DB=sqlite3
|
@@ -13,10 +12,9 @@ env:
|
|
13
12
|
- DB=postgresql
|
14
13
|
|
15
14
|
gemfile:
|
15
|
+
- gemfiles/activerecord_5.1.gemfile
|
16
16
|
- gemfiles/activerecord_5.0.gemfile
|
17
17
|
- gemfiles/activerecord_4.2.gemfile
|
18
|
-
- gemfiles/activerecord_4.1.gemfile
|
19
|
-
- gemfiles/activerecord_4.0.gemfile
|
20
18
|
|
21
19
|
sudo: false
|
22
20
|
|
@@ -28,9 +26,4 @@ before_install:
|
|
28
26
|
script: bundle exec rake
|
29
27
|
|
30
28
|
matrix:
|
31
|
-
exclude:
|
32
|
-
- rvm: 2.0.0
|
33
|
-
gemfile: gemfiles/activerecord_5.0.gemfile
|
34
|
-
- rvm: 2.1
|
35
|
-
gemfile: gemfiles/activerecord_5.0.gemfile
|
36
29
|
fast_finish: true
|
data/Appraisals
CHANGED
@@ -1,17 +1,11 @@
|
|
1
|
-
appraise 'activerecord-5.
|
2
|
-
gem 'activerecord', "~> 5.
|
3
|
-
end
|
4
|
-
|
5
|
-
appraise "activerecord-4.2" do
|
6
|
-
gem "activerecord", "~> 4.2.0"
|
1
|
+
appraise 'activerecord-5.1' do
|
2
|
+
gem 'activerecord', "~> 5.1.1"
|
7
3
|
end
|
8
4
|
|
9
|
-
appraise
|
10
|
-
gem
|
11
|
-
gem 'mysql2', '~> 0.3.21'
|
5
|
+
appraise 'activerecord-5.0' do
|
6
|
+
gem 'activerecord', "~> 5.0.3"
|
12
7
|
end
|
13
8
|
|
14
|
-
appraise "activerecord-4.
|
15
|
-
gem "activerecord", "~> 4.
|
16
|
-
|
17
|
-
end
|
9
|
+
appraise "activerecord-4.2" do
|
10
|
+
gem "activerecord", "~> 4.2.8"
|
11
|
+
end
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,88 @@ Each change should fall into categories that would affect whether the release is
|
|
4
4
|
|
5
5
|
As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
|
6
6
|
|
7
|
+
### [5.0.0 / 2017-05-18](https://github.com/mbleigh/acts-as-taggable-on/compare/v4.0.0...v5.0.0)
|
8
|
+
* Breaking Changes
|
9
|
+
* [@seuros Drop support for old version of ActiveRecord and Ruby and prepare rel](https://github.com/mbleigh/acts-as-taggable-on/pull/828)
|
10
|
+
* Added
|
11
|
+
* [@rbritom Tagged with rewrite](https://github.com/mbleigh/acts-as-taggable-on/pull/829)
|
12
|
+
* [@fearenales Due to database collisions, retry finding or creating a tag](https://github.com/mbleigh/acts-as-taggable-on/pull/809)
|
13
|
+
* [@brilyuhns Add owner_tags method to taggable](https://github.com/mbleigh/acts-as-taggable-on/pull/771)
|
14
|
+
* [@brilyuhns upport array of contexts in owner_tags_on method](https://github.com/mbleigh/acts-as-taggable-on/pull/771)
|
15
|
+
* [@brilyuhns Add specs for owner_tags_on and owner_tags methods](https://github.com/mbleigh/acts-as-taggable-on/pull/771)
|
16
|
+
* Fixes
|
17
|
+
* [@rbritom bump ruby versions for travis](https://github.com/mbleigh/acts-as-taggable-on/pull/825)
|
18
|
+
* [@mnrk Fixed Rails 5.1 deprecation message, has_many needs String value for](https://github.com/mbleigh/acts-as-taggable-on/pull/813)
|
19
|
+
* [@ProGM ProGM Adding a test to demonstrate the bug](https://github.com/mbleigh/acts-as-taggable-on/pull/806)
|
20
|
+
* [@ProGM ProGM Ensure that `caching_tag_list_on?` is injected before using it](https://github.com/mbleigh/acts-as-taggable-on/pull/806)
|
21
|
+
* [@ProGM ProGM Fix insert query for postgresql. Move schema definition in schema.rb](https://github.com/mbleigh/acts-as-taggable-on/pull/806)
|
22
|
+
* [@amatsuda assigned but unused variable - any](https://github.com/mbleigh/acts-as-taggable-on/pull/787)
|
23
|
+
* [@gmcnaughton Fix incorrect call of 'self.class' on methods which are already class](https://github.com/mbleigh/acts-as-taggable-on/pull/782)
|
24
|
+
* [@gmcnaughton Fixed #712 (incompatibility with ActiveRecord::Sanitization#quoted_id)](https://github.com/mbleigh/acts-as-taggable-on/pull/782)
|
25
|
+
* [@arpitchauhan Guard against indexes already existing](https://github.com/mbleigh/acts-as-taggable-on/pull/779)
|
26
|
+
* [@arpitchauhan Rename migration to avoid conflicts](https://github.com/mbleigh/acts-as-taggable-on/pull/774)
|
27
|
+
* [@lukeasrodgers "Bugfix `TagList#concat` with non-duplicates."](https://github.com/mbleigh/acts-as-taggable-on/pull/729)
|
28
|
+
* [@fabn Revert "Added missed indexes."](https://github.com/mbleigh/acts-as-taggable-on/pull/709)
|
29
|
+
* Documentation
|
30
|
+
* [Corey Osman Adds a table of contents to the readme and contributing files](https://github.com/mbleigh/acts-as-taggable-on/pull/803)
|
31
|
+
* [@ashishg-qburst Fix typo in README](https://github.com/mbleigh/acts-as-taggable-on/pull/800)
|
32
|
+
* [@praveenangyan Update README.md](https://github.com/mbleigh/acts-as-taggable-on/pull/798)
|
33
|
+
* [@colemerrick update finding tagged objects in readme](https://github.com/mbleigh/acts-as-taggable-on/pull/794)
|
34
|
+
* [jaredbeck Help people upgrade to 4.0.0](https://github.com/mbleigh/acts-as-taggable-on/pull/784)
|
35
|
+
* [@vasinov Update README.md](https://github.com/mbleigh/acts-as-taggable-on/pull/776)
|
36
|
+
|
37
|
+
### [4.0.0 / 2016-08-08](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.5.0...v4.0.0)
|
38
|
+
* Breaking Changes
|
39
|
+
* [@krzysiek1507 drop support for Ruby < 2 ](https://github.com/mbleigh/acts-as-taggable-on/pull/758)
|
40
|
+
* [@krzysiek1507 drop support for Rails < 4 ](https://github.com/mbleigh/acts-as-taggable-on/pull/757)
|
41
|
+
* Added
|
42
|
+
* [@jessieay Rails 5 ](https://github.com/mbleigh/acts-as-taggable-on/pull/763)
|
43
|
+
* Fixes
|
44
|
+
* [@rikettsie #623 collation parameter is ignored if it generates an exception] (https://github.com/mbleigh/acts-as-taggable-on/pull/650 )
|
45
|
+
* [@bwvoss References working parser in deprectation warning] (https://github.com/mbleigh/acts-as-taggable-on/pull/659 )
|
46
|
+
* [@jh125486 Updated tagging_contexts to include dynamic contexts ](https://github.com/mbleigh/acts-as-taggable-on/pull/660 )
|
47
|
+
* [@jh125486 Fixed wildcard test (postgres returning rows with unexpected order)] (https://github.com/mbleigh/acts-as-taggable-on/pull/660 )
|
48
|
+
* [@FlowerWrong Add rails 5.0.0 alpha support, not hack rails <5](https://github.com/mbleigh/acts-as-taggable-on/pull/673 )
|
49
|
+
* [@ryanfox1985 Added missed indexes. ](https://github.com/mbleigh/acts-as-taggable-on/pull/682 )
|
50
|
+
* [@ zapnap scope tags to specific tagging ](https://github.com/mbleigh/acts-as-taggable-on/pull/697 )
|
51
|
+
* [@ amatsuda method redefined](https://github.com/mbleigh/acts-as-taggable-on/pull/715 )
|
52
|
+
* [@ klacointe Rails 5: Tagger is optional in Tagging relation](https://github.com/mbleigh/acts-as-taggable-on/pull/720 )
|
53
|
+
* [@ mark-jacobs Update clean! method to use case insensitive uniq! when strict_case_match false] (https://github.com/mbleigh/acts-as-taggable-on/commit/90c86994b70a399b8b1cbc0ae88835e14d6aadfc )
|
54
|
+
* [@ lukeasrodgers BugFix flackey time test ] (https://github.com/mbleigh/acts-as-taggable-on/pull/727)
|
55
|
+
* [@ pcupueran Add rspec tests for context scopes for tagging_spec ]( https://github.com/mbleigh/acts-as-taggable-on/pull/740)
|
56
|
+
* [@ Emerson Huitt Remove existing selects from relation ]( https://github.com/mbleigh/acts-as-taggable-on/pull/743)
|
57
|
+
* [@keerthisiv fix issue with custom delimiter]( https://github.com/mbleigh/acts-as-taggable-on/pull/748)
|
58
|
+
* [@priyank-gupta specify tag table name for mysql collation query ](https://github.com/mbleigh/acts-as-taggable-on/pull/760)
|
59
|
+
* [@seuros Remove warning messages](https://github.com/mbleigh/acts-as-taggable-on/commit/cda08c764b07a18b8582b948d1c5b3910a3769 65)
|
60
|
+
* [@rbritom Fix migration, #references already adds index ]
|
61
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/95f743010954b6b738a6e8c17315112c878f7a81 )
|
62
|
+
* [@rbritom Fix deprecation warning]
|
63
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/62e4a6fa74ae3faed615683cd3ad5b5cdacf5c96 )
|
64
|
+
* [@rbritom fix scope array arguments ]
|
65
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/a415a8d6367b2e91bd7e363589135f953929b8cc )
|
66
|
+
* [@seuros Remove more deprecations ]
|
67
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/05794170f64f8bf250b34d2d594e368721009278)
|
68
|
+
* [@lukeasrodgers Bugfix `TagList#concat` with non-duplicates. ]
|
69
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/2c6214f0ddf8c6440ab81eec04d1fbf9d97c8826)
|
70
|
+
* [@seuros clean! should return self. ]
|
71
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/c739422f56f8ff37e3f321235e74997422a1c980)
|
72
|
+
* [@rbritom renable appraisals ]
|
73
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/0ca1f1c5b059699c683a28b522e86a3d5cd7639e)
|
74
|
+
* [@rbritom remove index conditionally on up method. ]
|
75
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/9cc580e7f88164634eb10c8826e5b30ea0e00544)
|
76
|
+
*[@rbritom add index on down method . ]
|
77
|
+
(https://github.com/mbleigh/acts-as-taggable-on/pull/767)
|
78
|
+
q* [@rbritom remove index conditionally on up method]
|
79
|
+
(https://github.com/mbleigh/acts-as-taggable-on/commit/9cc580e7f88164634eb10c8826e5b30ea0e00544)
|
80
|
+
|
81
|
+
* Documentation
|
82
|
+
* [@logicminds Adds table of contents using doctoc utility](https://github.com/mbleigh/acts-as-taggable-on/pull/803)
|
83
|
+
* [@jamesprior Changing ActsAsTaggable to ActsAsTaggableOn ](https://github.com/mbleigh/acts-as-taggable-on/pull/637)
|
84
|
+
* [@markgandolfo Update README.md](https://github.com/mbleigh/acts-as-taggable-on/pull/645))
|
85
|
+
* [@snowblink Update release date for 3.5.0](https://github.com/mbleigh/acts-as-taggable-on/pull/647)
|
86
|
+
* [@AlexVPopov Update README.md ](https://github.com/mbleigh/acts-as-taggable-on/pull/671)
|
87
|
+
* [@schnmudgal README.md, Improve documentation for Tag Ownership](https://github.com/mbleigh/acts-as-taggable-on/pull/706)
|
88
|
+
|
7
89
|
### [3.5.0 / 2015-03-03](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.4.4...v3.5.0)
|
8
90
|
|
9
91
|
* Fixes
|
data/CONTRIBUTING.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
3
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
4
|
+
|
5
|
+
- [How to contribute:](#how-to-contribute)
|
6
|
+
- [Bug reports / Issues](#bug-reports--issues)
|
7
|
+
- [Code](#code)
|
8
|
+
- [Commit Messages](#commit-messages)
|
9
|
+
- [About Pull Requests (PR's)](#about-pull-requests-prs)
|
10
|
+
- [Documentation](#documentation)
|
11
|
+
|
12
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
13
|
+
|
1
14
|
# How to contribute:
|
2
15
|
|
3
16
|
## Bug reports / Issues
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,41 @@
|
|
1
|
+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
2
|
+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
3
|
+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
|
4
|
+
|
5
|
+
- [ActsAsTaggableOn](#actsastaggableon)
|
6
|
+
- [Installation](#installation)
|
7
|
+
- [Post Installation](#post-installation)
|
8
|
+
- [For MySql users](#for-mysql-users)
|
9
|
+
- [Usage](#usage)
|
10
|
+
- [Finding most or least used tags](#finding-most-or-least-used-tags)
|
11
|
+
- [Finding Tagged Objects](#finding-tagged-objects)
|
12
|
+
- [Relationships](#relationships)
|
13
|
+
- [Dynamic Tag Contexts](#dynamic-tag-contexts)
|
14
|
+
- [Tag Parsers](#tag-parsers)
|
15
|
+
- [Tag Ownership](#tag-ownership)
|
16
|
+
- [Working with Owned Tags](#working-with-owned-tags)
|
17
|
+
- [Adding owned tags](#adding-owned-tags)
|
18
|
+
- [Removing owned tags](#removing-owned-tags)
|
19
|
+
- [Dirty objects](#dirty-objects)
|
20
|
+
- [Tag cloud calculations](#tag-cloud-calculations)
|
21
|
+
- [Configuration](#configuration)
|
22
|
+
- [Upgrading](#upgrading)
|
23
|
+
- [Contributors](#contributors)
|
24
|
+
- [Compatibility](#compatibility)
|
25
|
+
- [TODO](#todo)
|
26
|
+
- [Testing](#testing)
|
27
|
+
- [License](#license)
|
28
|
+
|
29
|
+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
30
|
+
|
1
31
|
# ActsAsTaggableOn
|
2
32
|
|
3
33
|
[](https://gitter.im/mbleigh/acts-as-taggable-on?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
34
|
[](http://badge.fury.io/rb/acts-as-taggable-on)
|
5
|
-
[](http://travis-ci.org/mbleigh/acts-as-taggable-on)
|
36
|
+
[](https://codeclimate.com/github/mbleigh/acts-as-taggable-on)
|
37
|
+
[](http://inch-ci.org/github/mbleigh/acts-as-taggable-on)
|
38
|
+
[](https://hakiri.io/github/mbleigh/acts-as-taggable-on/master)
|
8
39
|
|
9
40
|
This plugin was originally based on Acts as Taggable on Steroids by Jonathan Viney.
|
10
41
|
It has evolved substantially since that point, but all credit goes to him for the
|
@@ -207,12 +238,13 @@ User.tagged_with("awesome").by_join_date
|
|
207
238
|
User.tagged_with("awesome").by_join_date.paginate(:page => params[:page], :per_page => 20)
|
208
239
|
|
209
240
|
# Find users that matches all given tags:
|
241
|
+
# NOTE: This only matches users that have the exact set of specified tags. If a user has additional tags, they are not returned.
|
210
242
|
User.tagged_with(["awesome", "cool"], :match_all => true)
|
211
243
|
|
212
244
|
# Find users with any of the specified tags:
|
213
245
|
User.tagged_with(["awesome", "cool"], :any => true)
|
214
246
|
|
215
|
-
# Find users that
|
247
|
+
# Find users that have not been tagged with awesome or cool:
|
216
248
|
User.tagged_with(["awesome", "cool"], :exclude => true)
|
217
249
|
|
218
250
|
# Find users with any of the tags based on context:
|
@@ -332,12 +364,12 @@ Note that **owned tags** are added all at once, in the form of ***comma seperate
|
|
332
364
|
Also, when you try to add **owned tags** again, it simply overwrites the previous set of **owned tags**.
|
333
365
|
So to append tags in previously existing **owned tags** list, go as follows:
|
334
366
|
```ruby
|
335
|
-
def add_owned_tag
|
367
|
+
def add_owned_tag
|
336
368
|
@some_item = Item.find(params[:id])
|
337
|
-
owned_tag_list = @some_item.
|
369
|
+
owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
|
338
370
|
owned_tag_list += [(params[:tag])]
|
339
371
|
@tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
|
340
|
-
@some_item.save
|
372
|
+
@some_item.save
|
341
373
|
end
|
342
374
|
|
343
375
|
def stringify(tag_list)
|
@@ -347,12 +379,12 @@ end
|
|
347
379
|
##### Removing owned tags
|
348
380
|
Similarly as above, removing will be as follows:
|
349
381
|
```ruby
|
350
|
-
def remove_owned_tag
|
382
|
+
def remove_owned_tag
|
351
383
|
@some_item = Item.find(params[:id])
|
352
|
-
owned_tag_list = @some_item.
|
384
|
+
owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
|
353
385
|
owned_tag_list -= [(params[:tag])]
|
354
386
|
@tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
|
355
|
-
@some_item.save
|
387
|
+
@some_item.save
|
356
388
|
end
|
357
389
|
```
|
358
390
|
|
data/acts-as-taggable-on.gemspec
CHANGED
@@ -16,13 +16,13 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.test_files = gem.files.grep(%r{^spec/})
|
18
18
|
gem.require_paths = ['lib']
|
19
|
-
gem.required_ruby_version = '>= 2.
|
19
|
+
gem.required_ruby_version = '>= 2.2.7'
|
20
20
|
|
21
21
|
if File.exist?('UPGRADING.md')
|
22
22
|
gem.post_install_message = File.read('UPGRADING.md')
|
23
23
|
end
|
24
24
|
|
25
|
-
gem.add_runtime_dependency 'activerecord', ['>= 4.
|
25
|
+
gem.add_runtime_dependency 'activerecord', ['>= 4.2.8']
|
26
26
|
|
27
27
|
gem.add_development_dependency 'sqlite3'
|
28
28
|
gem.add_development_dependency 'mysql2', '~> 0.3'
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
2
|
+
class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
|
3
|
+
else
|
4
|
+
class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
|
5
|
+
end
|
6
|
+
ActsAsTaggableOnMigration.class_eval do
|
2
7
|
def self.up
|
3
8
|
create_table :tags do |t|
|
4
9
|
t.string :name
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
2
|
+
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
|
3
|
+
else
|
4
|
+
class AddMissingUniqueIndices < ActiveRecord::Migration; end
|
5
|
+
end
|
6
|
+
AddMissingUniqueIndices.class_eval do
|
2
7
|
def self.up
|
3
8
|
add_index :tags, :name, unique: true
|
4
9
|
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
2
|
+
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
|
3
|
+
else
|
4
|
+
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
|
5
|
+
end
|
6
|
+
AddTaggingsCounterCacheToTags.class_eval do
|
2
7
|
def self.up
|
3
8
|
add_column :tags, :taggings_count, :integer, default: 0
|
4
9
|
|
@@ -1,4 +1,9 @@
|
|
1
|
-
|
1
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
2
|
+
class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
|
3
|
+
else
|
4
|
+
class AddMissingTaggableIndex < ActiveRecord::Migration; end
|
5
|
+
end
|
6
|
+
AddMissingTaggableIndex.class_eval do
|
2
7
|
def self.up
|
3
8
|
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
4
9
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
# This migration is added to circumvent issue #623 and have special characters
|
2
2
|
# work properly
|
3
|
-
|
3
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
4
|
+
class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
|
5
|
+
else
|
6
|
+
class ChangeCollationForTagNames < ActiveRecord::Migration; end
|
7
|
+
end
|
8
|
+
ChangeCollationForTagNames.class_eval do
|
4
9
|
def up
|
5
10
|
if ActsAsTaggableOn::Utils.using_mysql?
|
6
11
|
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
|
@@ -0,0 +1,22 @@
|
|
1
|
+
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
|
2
|
+
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
|
3
|
+
else
|
4
|
+
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
|
5
|
+
end
|
6
|
+
AddMissingIndexesOnTaggings.class_eval do
|
7
|
+
def change
|
8
|
+
add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
|
9
|
+
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
|
10
|
+
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
|
11
|
+
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
|
12
|
+
add_index :taggings, :context unless index_exists? :taggings, :context
|
13
|
+
|
14
|
+
unless index_exists? :taggings, [:tagger_id, :tagger_type]
|
15
|
+
add_index :taggings, [:tagger_id, :tagger_type]
|
16
|
+
end
|
17
|
+
|
18
|
+
unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
|
19
|
+
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 4.2.
|
5
|
+
gem "activerecord", "~> 4.2.8"
|
6
6
|
|
7
7
|
group :local_development do
|
8
8
|
gem "guard"
|
9
9
|
gem "guard-rspec"
|
10
10
|
gem "appraisal"
|
11
11
|
gem "rake"
|
12
|
-
gem "byebug", :
|
12
|
+
gem "byebug", platforms: [:mri_21, :mri_22, :mri_23]
|
13
13
|
end
|
14
14
|
|
15
|
-
gemspec :
|
15
|
+
gemspec path: "../"
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 5.0.
|
5
|
+
gem "activerecord", "~> 5.0.3"
|
6
6
|
|
7
7
|
group :local_development do
|
8
8
|
gem "guard"
|
9
9
|
gem "guard-rspec"
|
10
10
|
gem "appraisal"
|
11
11
|
gem "rake"
|
12
|
-
gem "byebug", :
|
12
|
+
gem "byebug", platforms: [:mri_21, :mri_22, :mri_23]
|
13
13
|
end
|
14
14
|
|
15
|
-
gemspec :
|
15
|
+
gemspec path: "../"
|
@@ -2,15 +2,14 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~>
|
6
|
-
gem "mysql2", "~> 0.3.21"
|
5
|
+
gem "activerecord", "~> 5.1.1"
|
7
6
|
|
8
7
|
group :local_development do
|
9
8
|
gem "guard"
|
10
9
|
gem "guard-rspec"
|
11
10
|
gem "appraisal"
|
12
11
|
gem "rake"
|
13
|
-
gem "byebug", :
|
12
|
+
gem "byebug", platforms: [:mri_21, :mri_22, :mri_23]
|
14
13
|
end
|
15
14
|
|
16
|
-
gemspec :
|
15
|
+
gemspec path: "../"
|
@@ -69,17 +69,20 @@ module ActsAsTaggableOn
|
|
69
69
|
|
70
70
|
return [] if list.empty?
|
71
71
|
|
72
|
-
existing_tags = named_any(list)
|
73
|
-
|
74
72
|
list.map do |tag_name|
|
75
|
-
comparable_tag_name = comparable_name(tag_name)
|
76
|
-
existing_tag = existing_tags.find { |tag| comparable_name(tag.name) == comparable_tag_name }
|
77
73
|
begin
|
74
|
+
tries ||= 3
|
75
|
+
|
76
|
+
existing_tags = named_any(list)
|
77
|
+
comparable_tag_name = comparable_name(tag_name)
|
78
|
+
existing_tag = existing_tags.find { |tag| comparable_name(tag.name) == comparable_tag_name }
|
78
79
|
existing_tag || create(name: tag_name)
|
79
80
|
rescue ActiveRecord::RecordNotUnique
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
if (tries -= 1).positive?
|
82
|
+
ActiveRecord::Base.connection.execute 'ROLLBACK'
|
83
|
+
retry
|
84
|
+
end
|
85
|
+
|
83
86
|
raise DuplicateTagError.new("'#{tag_name}' has already been taken")
|
84
87
|
end
|
85
88
|
end
|