acts-as-taggable-on 4.0.0.pre → 7.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 +5 -5
- data/.gitignore +1 -1
- data/.travis.yml +28 -15
- data/Appraisals +12 -10
- data/CHANGELOG.md +200 -71
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +1 -1
- data/README.md +68 -28
- data/acts-as-taggable-on.gemspec +2 -6
- data/db/migrate/1_acts_as_taggable_on_migration.rb +14 -8
- data/db/migrate/2_add_missing_unique_indices.rb +14 -9
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +9 -4
- data/db/migrate/4_add_missing_taggable_index.rb +8 -3
- data/db/migrate/5_change_collation_for_tag_names.rb +7 -2
- data/db/migrate/6_add_missing_indexes_on_taggings.rb +22 -0
- data/gemfiles/activerecord_5.0.gemfile +11 -5
- data/gemfiles/activerecord_5.1.gemfile +21 -0
- data/gemfiles/activerecord_5.2.gemfile +21 -0
- data/gemfiles/activerecord_6.0.gemfile +21 -0
- data/gemfiles/activerecord_6.1.gemfile +23 -0
- data/lib/acts-as-taggable-on.rb +6 -2
- data/lib/acts_as_taggable_on/tag.rb +17 -23
- data/lib/acts_as_taggable_on/tag_list.rb +1 -0
- data/lib/acts_as_taggable_on/taggable.rb +0 -1
- data/lib/acts_as_taggable_on/taggable/cache.rb +38 -34
- data/lib/acts_as_taggable_on/taggable/collection.rb +9 -7
- data/lib/acts_as_taggable_on/taggable/core.rb +41 -181
- data/lib/acts_as_taggable_on/taggable/ownership.rb +16 -5
- data/lib/acts_as_taggable_on/taggable/related.rb +1 -1
- data/lib/acts_as_taggable_on/taggable/tag_list_type.rb +4 -0
- 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 +111 -0
- data/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb +70 -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 +3 -3
- data/lib/acts_as_taggable_on/tagging.rb +6 -3
- data/lib/acts_as_taggable_on/utils.rb +4 -4
- data/lib/acts_as_taggable_on/version.rb +1 -2
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +4 -12
- data/spec/acts_as_taggable_on/caching_spec.rb +34 -10
- data/spec/acts_as_taggable_on/{taggable/dirty_spec.rb → dirty_spec.rb} +28 -13
- data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +28 -8
- data/spec/acts_as_taggable_on/taggable_spec.rb +16 -13
- data/spec/acts_as_taggable_on/tagger_spec.rb +2 -2
- data/spec/internal/app/models/altered_inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/cached_model_with_array.rb +6 -0
- data/spec/internal/app/models/columns_override_model.rb +5 -0
- data/spec/internal/app/models/company.rb +1 -1
- data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/market.rb +1 -1
- data/spec/internal/app/models/non_standard_id_taggable_model.rb +1 -1
- data/spec/internal/app/models/student.rb +2 -0
- data/spec/internal/app/models/taggable_model.rb +1 -0
- data/spec/internal/app/models/user.rb +1 -1
- data/spec/internal/db/schema.rb +14 -5
- data/spec/spec_helper.rb +0 -1
- data/spec/support/database.rb +4 -4
- metadata +30 -61
- data/db/migrate/6_add_missing_indexes.rb +0 -12
- data/gemfiles/activerecord_4.0.gemfile +0 -16
- data/gemfiles/activerecord_4.1.gemfile +0 -16
- data/gemfiles/activerecord_4.2.gemfile +0 -15
- data/lib/acts_as_taggable_on/taggable/dirty.rb +0 -36
- data/spec/internal/app/models/models.rb +0 -90
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
|
@@ -19,22 +50,14 @@ Enter Acts as Taggable On. Rather than tying functionality to a specific keyword
|
|
19
50
|
tag "contexts" that can be used locally or in combination in the same way steroids
|
20
51
|
was used.
|
21
52
|
|
22
|
-
## Compatibility
|
23
|
-
|
24
|
-
Versions 2.x are compatible with Ruby 1.8.7+ and Rails 3.
|
25
|
-
|
26
|
-
Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and cwoodcox).
|
27
53
|
|
28
|
-
Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
|
29
|
-
|
30
|
-
For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
|
31
54
|
|
32
55
|
## Installation
|
33
56
|
|
34
57
|
To use it, add it to your Gemfile:
|
35
58
|
|
36
59
|
```ruby
|
37
|
-
gem 'acts-as-taggable-on', '~>
|
60
|
+
gem 'acts-as-taggable-on', '~> 6.0'
|
38
61
|
```
|
39
62
|
|
40
63
|
and bundle:
|
@@ -50,8 +73,6 @@ Install migrations
|
|
50
73
|
```shell
|
51
74
|
# For the latest versions :
|
52
75
|
rake acts_as_taggable_on_engine:install:migrations
|
53
|
-
# For versions 2.4.1 and earlier :
|
54
|
-
rails generate acts_as_taggable_on:migration
|
55
76
|
```
|
56
77
|
|
57
78
|
Review the generated migrations then migrate :
|
@@ -75,9 +96,6 @@ rake acts_as_taggable_on_engine:tag_names:collate_bin
|
|
75
96
|
See the Configuration section for more details, and a general note valid for older
|
76
97
|
version of the gem.
|
77
98
|
|
78
|
-
#### Upgrading
|
79
|
-
|
80
|
-
see [UPGRADING](UPGRADING.md)
|
81
99
|
|
82
100
|
## Usage
|
83
101
|
|
@@ -85,8 +103,8 @@ Setup
|
|
85
103
|
|
86
104
|
```ruby
|
87
105
|
class User < ActiveRecord::Base
|
88
|
-
|
89
|
-
acts_as_taggable_on :skills, :interests
|
106
|
+
acts_as_taggable_on :tags
|
107
|
+
acts_as_taggable_on :skills, :interests #You can also configure multiple tag types per model
|
90
108
|
end
|
91
109
|
|
92
110
|
class UsersController < ApplicationController
|
@@ -103,6 +121,7 @@ Add and remove a single tag
|
|
103
121
|
```ruby
|
104
122
|
@user.tag_list.add("awesome") # add a single tag. alias for <<
|
105
123
|
@user.tag_list.remove("awesome") # remove a single tag
|
124
|
+
@user.save # save to persist tag_list
|
106
125
|
```
|
107
126
|
|
108
127
|
Add and remove multiple tags in an array
|
@@ -110,6 +129,7 @@ Add and remove multiple tags in an array
|
|
110
129
|
```ruby
|
111
130
|
@user.tag_list.add("awesome", "slick")
|
112
131
|
@user.tag_list.remove("awesome", "slick")
|
132
|
+
@user.save
|
113
133
|
```
|
114
134
|
|
115
135
|
You can also add and remove tags in format of String. This would
|
@@ -220,12 +240,13 @@ User.tagged_with("awesome").by_join_date
|
|
220
240
|
User.tagged_with("awesome").by_join_date.paginate(:page => params[:page], :per_page => 20)
|
221
241
|
|
222
242
|
# Find users that matches all given tags:
|
243
|
+
# NOTE: This only matches users that have the exact set of specified tags. If a user has additional tags, they are not returned.
|
223
244
|
User.tagged_with(["awesome", "cool"], :match_all => true)
|
224
245
|
|
225
246
|
# Find users with any of the specified tags:
|
226
247
|
User.tagged_with(["awesome", "cool"], :any => true)
|
227
248
|
|
228
|
-
# Find users that
|
249
|
+
# Find users that have not been tagged with awesome or cool:
|
229
250
|
User.tagged_with(["awesome", "cool"], :exclude => true)
|
230
251
|
|
231
252
|
# Find users with any of the tags based on context:
|
@@ -345,12 +366,12 @@ Note that **owned tags** are added all at once, in the form of ***comma seperate
|
|
345
366
|
Also, when you try to add **owned tags** again, it simply overwrites the previous set of **owned tags**.
|
346
367
|
So to append tags in previously existing **owned tags** list, go as follows:
|
347
368
|
```ruby
|
348
|
-
def add_owned_tag
|
369
|
+
def add_owned_tag
|
349
370
|
@some_item = Item.find(params[:id])
|
350
|
-
owned_tag_list = @some_item.
|
371
|
+
owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
|
351
372
|
owned_tag_list += [(params[:tag])]
|
352
373
|
@tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
|
353
|
-
@some_item.save
|
374
|
+
@some_item.save
|
354
375
|
end
|
355
376
|
|
356
377
|
def stringify(tag_list)
|
@@ -360,12 +381,12 @@ end
|
|
360
381
|
##### Removing owned tags
|
361
382
|
Similarly as above, removing will be as follows:
|
362
383
|
```ruby
|
363
|
-
def remove_owned_tag
|
384
|
+
def remove_owned_tag
|
364
385
|
@some_item = Item.find(params[:id])
|
365
|
-
owned_tag_list = @some_item.
|
386
|
+
owned_tag_list = @some_item.all_tags_list - @some_item.tag_list
|
366
387
|
owned_tag_list -= [(params[:tag])]
|
367
388
|
@tag_owner.tag(@some_item, :with => stringify(owned_tag_list), :on => :tags)
|
368
|
-
@some_item.save
|
389
|
+
@some_item.save
|
369
390
|
end
|
370
391
|
```
|
371
392
|
|
@@ -467,6 +488,13 @@ If you would like to have an exact match covering special characters with MySql:
|
|
467
488
|
ActsAsTaggableOn.force_binary_collation = true
|
468
489
|
```
|
469
490
|
|
491
|
+
If you would like to specify table names:
|
492
|
+
|
493
|
+
```ruby
|
494
|
+
ActsAsTaggableOn.tags_table = 'aato_tags'
|
495
|
+
ActsAsTaggableOn.taggings_table = 'aato_taggings'
|
496
|
+
```
|
497
|
+
|
470
498
|
If you want to change the default delimiter (it defaults to ','). You can also pass in an array of delimiters such as ([',', '|']):
|
471
499
|
|
472
500
|
```ruby
|
@@ -484,13 +512,25 @@ USE my_wonderful_app_db;
|
|
484
512
|
ALTER TABLE tags MODIFY name VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin;
|
485
513
|
```
|
486
514
|
|
515
|
+
#### Upgrading
|
516
|
+
|
517
|
+
see [UPGRADING](UPGRADING.md)
|
518
|
+
|
487
519
|
## Contributors
|
488
520
|
|
489
521
|
We have a long list of valued contributors. [Check them all](https://github.com/mbleigh/acts-as-taggable-on/contributors)
|
490
522
|
|
491
|
-
##
|
523
|
+
## Compatibility
|
492
524
|
|
493
|
-
|
525
|
+
Versions 2.x are compatible with Ruby 1.8.7+ and Rails 3.
|
526
|
+
|
527
|
+
Versions 2.4.1 and up are compatible with Rails 4 too (thanks to arabonradar and cwoodcox).
|
528
|
+
|
529
|
+
Versions >= 3.x are compatible with Ruby 1.9.3+ and Rails 3 and 4.
|
530
|
+
|
531
|
+
Versions >= 4.x are compatible with Ruby 2.0.0+ and Rails 4 and 5.
|
532
|
+
|
533
|
+
For an up-to-date roadmap, see https://github.com/mbleigh/acts-as-taggable-on/milestones
|
494
534
|
|
495
535
|
## TODO
|
496
536
|
|
data/acts-as-taggable-on.gemspec
CHANGED
@@ -16,17 +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.3.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',
|
26
|
-
|
27
|
-
gem.add_development_dependency 'sqlite3'
|
28
|
-
gem.add_development_dependency 'mysql2', '~> 0.3'
|
29
|
-
gem.add_development_dependency 'pg'
|
25
|
+
gem.add_runtime_dependency 'activerecord', '>= 5.0', '< 6.2'
|
30
26
|
|
31
27
|
gem.add_development_dependency 'rspec-rails'
|
32
28
|
gem.add_development_dependency 'rspec-its'
|
@@ -1,11 +1,17 @@
|
|
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
|
-
create_table
|
8
|
+
create_table ActsAsTaggableOn.tags_table do |t|
|
4
9
|
t.string :name
|
10
|
+
t.timestamps
|
5
11
|
end
|
6
12
|
|
7
|
-
create_table
|
8
|
-
t.references :tag
|
13
|
+
create_table ActsAsTaggableOn.taggings_table do |t|
|
14
|
+
t.references :tag, foreign_key: { to_table: ActsAsTaggableOn.tags_table }
|
9
15
|
|
10
16
|
# You should make sure that the column created is
|
11
17
|
# long enough to store the required class names.
|
@@ -19,12 +25,12 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
|
19
25
|
t.datetime :created_at
|
20
26
|
end
|
21
27
|
|
22
|
-
add_index
|
23
|
-
add_index
|
28
|
+
add_index ActsAsTaggableOn.taggings_table, :tag_id
|
29
|
+
add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
|
24
30
|
end
|
25
31
|
|
26
32
|
def self.down
|
27
|
-
drop_table
|
28
|
-
drop_table
|
33
|
+
drop_table ActsAsTaggableOn.taggings_table
|
34
|
+
drop_table ActsAsTaggableOn.tags_table
|
29
35
|
end
|
30
36
|
end
|
@@ -1,20 +1,25 @@
|
|
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
|
-
add_index
|
8
|
+
add_index ActsAsTaggableOn.tags_table, :name, unique: true
|
4
9
|
|
5
|
-
remove_index
|
6
|
-
remove_index
|
7
|
-
add_index
|
10
|
+
remove_index ActsAsTaggableOn.taggings_table, :tag_id if index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
|
11
|
+
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
|
12
|
+
add_index ActsAsTaggableOn.taggings_table,
|
8
13
|
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
9
14
|
unique: true, name: 'taggings_idx'
|
10
15
|
end
|
11
16
|
|
12
17
|
def self.down
|
13
|
-
remove_index
|
18
|
+
remove_index ActsAsTaggableOn.tags_table, :name
|
14
19
|
|
15
|
-
remove_index
|
20
|
+
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_idx'
|
16
21
|
|
17
|
-
add_index
|
18
|
-
add_index
|
22
|
+
add_index ActsAsTaggableOn.taggings_table, :tag_id unless index_exists?(ActsAsTaggableOn.taggings_table, :tag_id)
|
23
|
+
add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
|
19
24
|
end
|
20
25
|
end
|
@@ -1,14 +1,19 @@
|
|
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
|
-
add_column
|
8
|
+
add_column ActsAsTaggableOn.tags_table, :taggings_count, :integer, default: 0
|
4
9
|
|
5
10
|
ActsAsTaggableOn::Tag.reset_column_information
|
6
11
|
ActsAsTaggableOn::Tag.find_each do |tag|
|
7
|
-
ActsAsTaggableOn::Tag.reset_counters(tag.id,
|
12
|
+
ActsAsTaggableOn::Tag.reset_counters(tag.id, ActsAsTaggableOn.taggings_table)
|
8
13
|
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def self.down
|
12
|
-
remove_column
|
17
|
+
remove_column ActsAsTaggableOn.tags_table, :taggings_count
|
13
18
|
end
|
14
19
|
end
|
@@ -1,9 +1,14 @@
|
|
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
|
-
add_index
|
8
|
+
add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :context], name: 'taggings_taggable_context_idx'
|
4
9
|
end
|
5
10
|
|
6
11
|
def self.down
|
7
|
-
remove_index
|
12
|
+
remove_index ActsAsTaggableOn.taggings_table, name: 'taggings_taggable_context_idx'
|
8
13
|
end
|
9
14
|
end
|
@@ -1,9 +1,14 @@
|
|
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
|
-
execute("ALTER TABLE
|
11
|
+
execute("ALTER TABLE #{ActsAsTaggableOn.tags_table} MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
|
7
12
|
end
|
8
13
|
end
|
9
14
|
end
|
@@ -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 ActsAsTaggableOn.taggings_table, :tag_id unless index_exists? ActsAsTaggableOn.taggings_table, :tag_id
|
9
|
+
add_index ActsAsTaggableOn.taggings_table, :taggable_id unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_id
|
10
|
+
add_index ActsAsTaggableOn.taggings_table, :taggable_type unless index_exists? ActsAsTaggableOn.taggings_table, :taggable_type
|
11
|
+
add_index ActsAsTaggableOn.taggings_table, :tagger_id unless index_exists? ActsAsTaggableOn.taggings_table, :tagger_id
|
12
|
+
add_index ActsAsTaggableOn.taggings_table, :context unless index_exists? ActsAsTaggableOn.taggings_table, :context
|
13
|
+
|
14
|
+
unless index_exists? ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
|
15
|
+
add_index ActsAsTaggableOn.taggings_table, [:tagger_id, :tagger_type]
|
16
|
+
end
|
17
|
+
|
18
|
+
unless index_exists? ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
|
19
|
+
add_index ActsAsTaggableOn.taggings_table, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,15 +1,21 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
1
|
source "https://rubygems.org"
|
4
2
|
|
5
|
-
gem "activerecord", "~> 5.0.
|
3
|
+
gem "activerecord", "~> 5.0.3"
|
4
|
+
case ENV["DB"]
|
5
|
+
when "postgresql"
|
6
|
+
gem 'pg'
|
7
|
+
when "mysql"
|
8
|
+
gem 'mysql2', '~> 0.3'
|
9
|
+
else
|
10
|
+
gem "sqlite3", "~> 1.3", "< 1.4"
|
11
|
+
end
|
6
12
|
|
7
13
|
group :local_development do
|
8
14
|
gem "guard"
|
9
15
|
gem "guard-rspec"
|
10
16
|
gem "appraisal"
|
11
17
|
gem "rake"
|
12
|
-
gem "byebug", :
|
18
|
+
gem "byebug", platforms: [:mri]
|
13
19
|
end
|
14
20
|
|
15
|
-
gemspec :
|
21
|
+
gemspec path: "../"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gem "activerecord", "~> 5.1.1"
|
4
|
+
case ENV["DB"]
|
5
|
+
when "postgresql"
|
6
|
+
gem 'pg'
|
7
|
+
when "mysql"
|
8
|
+
gem 'mysql2', '~> 0.3'
|
9
|
+
else
|
10
|
+
gem "sqlite3", "~> 1.3", "< 1.4"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :local_development do
|
14
|
+
gem "guard"
|
15
|
+
gem "guard-rspec"
|
16
|
+
gem "appraisal"
|
17
|
+
gem "rake"
|
18
|
+
gem "byebug", platforms: [:mri]
|
19
|
+
end
|
20
|
+
|
21
|
+
gemspec path: "../"
|