gutentag 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/app/models/gutentag/tag.rb +3 -1
- data/app/models/gutentag/tagging.rb +2 -0
- data/db/migrate/1_gutentag_tables.rb +8 -8
- data/db/migrate/2_gutentag_cache_counter.rb +3 -3
- data/db/migrate/3_no_null_counters.rb +2 -2
- data/gutentag.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d85f0029e162907bb00faea63223b0b8c1207fec
|
4
|
+
data.tar.gz: fa0aee9f34395cb1af2885da0c70a04427e26da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bd5622a2935365c92ef8bab94768913a194fd34c98f28057beb8369b875d40e0797d525593bf7641daa9f360765d72560dd4998cdb8409d1241a4829cf7b5b7
|
7
|
+
data.tar.gz: 9b17cb1f4ae54e5205c6eaf8ee514c3e48bca171ee392ca18feb80562c5fdaae381eeeaefe912a537e922251d375fb152aa4b9c848784b53e5fe284a5444d36d
|
data/README.md
CHANGED
@@ -10,9 +10,14 @@ This was built partly as a proof-of-concept, and partly to see how a tagging gem
|
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
+
**Upgrading?** Gutentag has recently switched table names from `tags` and `taggings` to `gutentag_tags` and `gutentag_taggings`, to avoid conflicting with the more generic table names that may exist in Rails apps already. If you already have been using Gutentag, you'll need to create a migration manually that renames these tables:
|
14
|
+
|
15
|
+
rename_table :tags, :gutentag_tags
|
16
|
+
rename_table :taggings, :gutentag_taggings
|
17
|
+
|
13
18
|
Get it into your Gemfile - and don't forget the version constraint!
|
14
19
|
|
15
|
-
gem 'gutentag', '~> 0.
|
20
|
+
gem 'gutentag', '~> 0.5.0'
|
16
21
|
|
17
22
|
Next: your tags get persisted to your database, so let's import and run the migrations to get the tables set up:
|
18
23
|
|
data/app/models/gutentag/tag.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
class Gutentag::Tag < ActiveRecord::Base
|
2
|
+
self.table_name = 'gutentag_tags'
|
3
|
+
|
2
4
|
has_many :taggings, :class_name => 'Gutentag::Tagging',
|
3
5
|
:dependent => :destroy
|
4
6
|
|
5
7
|
attr_accessible :name if Rails.version.to_s < '4.0.0'
|
6
8
|
|
7
|
-
scope :by_weight, ->{ order('
|
9
|
+
scope :by_weight, ->{ order('gutentag_tags.taggings_count DESC') }
|
8
10
|
|
9
11
|
validates :name, :presence => true, :uniqueness => {:case_sensitive => false}
|
10
12
|
|
@@ -1,27 +1,27 @@
|
|
1
1
|
class GutentagTables < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
create_table :
|
3
|
+
create_table :gutentag_taggings do |t|
|
4
4
|
t.integer :tag_id, :null => false
|
5
5
|
t.integer :taggable_id, :null => false
|
6
6
|
t.string :taggable_type, :null => false
|
7
7
|
t.timestamps
|
8
8
|
end
|
9
9
|
|
10
|
-
add_index :
|
11
|
-
add_index :
|
12
|
-
add_index :
|
10
|
+
add_index :gutentag_taggings, :tag_id
|
11
|
+
add_index :gutentag_taggings, [:taggable_type, :taggable_id]
|
12
|
+
add_index :gutentag_taggings, [:taggable_type, :taggable_id, :tag_id],
|
13
13
|
:unique => true, :name => 'unique_taggings'
|
14
14
|
|
15
|
-
create_table :
|
15
|
+
create_table :gutentag_tags do |t|
|
16
16
|
t.string :name, :null => false
|
17
17
|
t.timestamps
|
18
18
|
end
|
19
19
|
|
20
|
-
add_index :
|
20
|
+
add_index :gutentag_tags, :name, :unique => true
|
21
21
|
end
|
22
22
|
|
23
23
|
def down
|
24
|
-
drop_table :
|
25
|
-
drop_table :
|
24
|
+
drop_table :gutentag_tags
|
25
|
+
drop_table :gutentag_taggings
|
26
26
|
end
|
27
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class GutentagCacheCounter < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
add_column :
|
4
|
-
add_index :
|
3
|
+
add_column :gutentag_tags, :taggings_count, :integer, :default => 0
|
4
|
+
add_index :gutentag_tags, :taggings_count
|
5
5
|
|
6
6
|
Gutentag::Tag.reset_column_information
|
7
7
|
Gutentag::Tag.pluck(:id).each do |tag_id|
|
@@ -10,6 +10,6 @@ class GutentagCacheCounter < ActiveRecord::Migration
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def down
|
13
|
-
remove_column :
|
13
|
+
remove_column :gutentag_tags, :taggings_count
|
14
14
|
end
|
15
15
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class NoNullCounters < ActiveRecord::Migration
|
2
2
|
def up
|
3
|
-
change_column :
|
3
|
+
change_column :gutentag_tags, :taggings_count, :integer, :default => 0,
|
4
4
|
:null => false
|
5
5
|
end
|
6
6
|
|
7
7
|
def down
|
8
|
-
change_column :
|
8
|
+
change_column :gutentag_tags, :taggings_count, :integer, :default => 0,
|
9
9
|
:null => true
|
10
10
|
end
|
11
11
|
end
|
data/gutentag.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gutentag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.0
|
123
|
+
rubygems_version: 2.1.0
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Good Tags
|