has_tags 0.0.3 → 0.0.4
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/README.md +3 -3
- data/lib/has_tags/taggable.rb +2 -1
- data/lib/has_tags/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad1ceeb59db26549f51f3470e4b2fd2dbeb0986
|
4
|
+
data.tar.gz: 31705964c92458f7296f341044343d9700223bf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7f42b7bd4fb85e5e2559242d90e8c3e43ed439e8e343f36b8c3380185873b24291d32b97853df8d7810952bdb6d1097caaecbac7353b07edee9bf2ed9652f24
|
7
|
+
data.tar.gz: 9ed1506104d3996713dc5bf9638df265ce1dd0aaa65f5e20933a6cd5f5a2e29af2053b483c24eb95786ab7a46b97bba290a5353f123006c0be10f54aab35333c
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ class PostController < ActiveRecord::Base
|
|
47
47
|
end
|
48
48
|
```
|
49
49
|
|
50
|
-
<code>tag_list</code> should be a string with tags separated by commas, or colons to
|
50
|
+
<code>tag_list</code> should be a string with tags separated by commas, or colons to create a context tag.
|
51
51
|
|
52
52
|
### Examples
|
53
53
|
|
@@ -62,7 +62,7 @@ For creating tags within tags, where to top-level tag acts as the context or par
|
|
62
62
|
This creates three tags: Sports, Hockey and Food. Sports is now the context in which Hockey lives. Now we can call:
|
63
63
|
|
64
64
|
```ruby
|
65
|
-
context = Tag.find_by(name: "Sports")
|
65
|
+
context = HasTags::Tag.find_by(name: "Sports")
|
66
66
|
|
67
67
|
context.tags # => Hockey tag
|
68
68
|
```
|
@@ -72,7 +72,7 @@ The context tag syntax can be nested like so:
|
|
72
72
|
"Sports:Hockey:Strategy"
|
73
73
|
|
74
74
|
```ruby
|
75
|
-
strategy = Tag.find_by(name: "Strategy")
|
75
|
+
strategy = HasTags::Tag.find_by(name: "Strategy")
|
76
76
|
|
77
77
|
hockey = strategy.context # => Hockey tag
|
78
78
|
|
data/lib/has_tags/taggable.rb
CHANGED
@@ -27,6 +27,7 @@ module HasTags
|
|
27
27
|
module InstanceMethods
|
28
28
|
def save_taggings
|
29
29
|
taggings = HasTags::Tagging.where(taggable_type: self.class.to_s, taggable_id: nil)
|
30
|
+
puts taggings.map(&:attributes)
|
30
31
|
taggings.each do |tagging|
|
31
32
|
tagging.taggable_id = self.id
|
32
33
|
tagging.save
|
@@ -46,7 +47,7 @@ module HasTags
|
|
46
47
|
else
|
47
48
|
tag = HasTags::Tag.where(name: name, context_id: Tag.find_by(name: names[index-1]).id).first_or_create!
|
48
49
|
end
|
49
|
-
HasTags::Tagging.where(tag_id: tag.id, taggable_type: self.class.to_s).
|
50
|
+
HasTags::Tagging.where(tag_id: tag.id, taggable_type: self.class.to_s).create!
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
data/lib/has_tags/version.rb
CHANGED