acts_as_metable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afb3211c561facc4b0984b62348e98a639e14cf6
|
4
|
+
data.tar.gz: c0ac35d0be537bff04532a0a0194ebf954dc1142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6922403915cacec2ca50d1814be6ffdd779cca63dcfd615d25063fd307e06cb485d703b2cda8675c1f78435ae5cec31e91358407dda25d82b0b4d4ad080f529
|
7
|
+
data.tar.gz: 3d4b22eaaef74422479ec34818ec12662149fa76f6e0aa907582e00c1a68dde852ceab03d4a83abe28a7304bcce0bc5b5b74cfd96b9c5937c76abc64e818ad01
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module ActsAsMetable
|
2
2
|
class Tag < ActiveRecord::Base
|
3
3
|
belongs_to :metable, polymorphic: true
|
4
|
+
|
5
|
+
validates_presence_of :metable_id, if: -> (tag) { tag.metable_type.present? }
|
6
|
+
validates_presence_of :metable_type, if: -> (tag) { tag.metable_id.present? }
|
7
|
+
validates_presence_of :uid, if: -> (tag) { tag.metable_id.blank? || tag.metable_type.blank? }
|
4
8
|
end
|
5
9
|
end
|
data/lib/acts_as_metable.rb
CHANGED
@@ -23,6 +23,12 @@ module ActsAsMetable
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def add_by_uid uid
|
27
|
+
ActsAsMetable::Tag.where(:uid => uid).each do |tag|
|
28
|
+
add_tag tag.name, tag.content
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
26
32
|
def render
|
27
33
|
result = @tags.map do |tag|
|
28
34
|
ActionController::Base.helpers.tag(:meta, name: tag[:name], content: tag[:content])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_metable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Novikov
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- Rakefile
|
51
51
|
- app/models/acts_as_metable/tag.rb
|
52
52
|
- db/migrate/20150913104251_create_acts_as_metable_tags.rb
|
53
|
+
- db/migrate/20150913142422_add_uid_to_acts_as_metable_tags.rb
|
53
54
|
- lib/acts_as_metable.rb
|
54
55
|
- lib/acts_as_metable/engine.rb
|
55
56
|
- lib/acts_as_metable/metable.rb
|