comment_me 0.1.1alpha → 0.2.0alpha

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
  SHA256:
3
- metadata.gz: 6baa29f00200bd82232ed816437851fabce25e6d994c40ca83b98f88a4092e06
4
- data.tar.gz: d93fd6a25223cc0db5b85457d59abd88ca1be154e2c39545fa283c48b6d80ef0
3
+ metadata.gz: 802fa515fa94d77a1d6a77fd3532ba753122c179fa81fb666255f4c36642eb10
4
+ data.tar.gz: 34afe2f0aa06c90e230b2e6196721f3167da3a4b82ece86a75a6107097dbc878
5
5
  SHA512:
6
- metadata.gz: dd5a3787bec239eb1df2cbfd1a5d8c667c80c72b4a015774ebbff8ff37425b97de7baa5c8132d17b4e2f12fa652366c6724ae6f7eca82b63423b681838cbcd02
7
- data.tar.gz: e3594f67f22a06f1f5f509f3875259f1b6abc6d4827f972ee650896b8c945d0fd06a57d4807a0501abf67c3da2b66e9e6d40ed1782dd5d34c042164ef0675893
6
+ metadata.gz: 2056f0677fa192405518a3243ef831ac1eb952f4136e6df36fbc5920ad5bd5fb48df4dee434ea2d8b8b3fb14880d67b099bfda3ec12ef092790855ddbb5df4e2
7
+ data.tar.gz: eee9c37ad5990466bff0b2935cf41ccdf42237448211c7184cf00a7c7a15205335d483fb972e994813c7967b85eb66c80fbbd66b06a63e8aa706e5426f4fefbd
data/README.md CHANGED
@@ -27,7 +27,7 @@ Then migrate the database:
27
27
 
28
28
  ```bash
29
29
  $ rails db:migrate
30
- ``
30
+ ```
31
31
 
32
32
  ## Usage
33
33
 
@@ -9,6 +9,7 @@ module CommentMe
9
9
 
10
10
  included do
11
11
  has_many :comments, -> { includes :comments }, as: :entity, dependent: :destroy
12
+ accepts_nested_attributes_for :comments
12
13
  end
13
14
  end
14
15
 
@@ -1,13 +1,15 @@
1
1
  class Comment < ActiveRecord::Base
2
2
 
3
3
  # => associations
4
- belongs_to :entity, polymorphic: true, optional: false
4
+ belongs_to :entity, polymorphic: true
5
5
  belongs_to :comment, optional: true
6
6
  has_many :comments, dependent: :destroy
7
7
 
8
8
  # => Validations
9
9
  validates_presence_of :emitter, :message
10
- validate :entity_existence, if: :entity_type?
10
+
11
+ # => callback
12
+ after_create :entity_existence
11
13
 
12
14
  # => *
13
15
  def entity_exist?
@@ -24,10 +26,7 @@ class Comment < ActiveRecord::Base
24
26
  # => *
25
27
  def entity_existence
26
28
  unless entity_exist?
27
- errors.add(
28
- :entity,
29
- "#{entity_type} doesn't have association with Comment or there's no record in #{entity_type} witn id=#{entity_id}"
30
- )
29
+ raise ActiveRecord::Rollback
31
30
  end
32
31
  end
33
32
  end
@@ -1,3 +1,3 @@
1
1
  module CommentMe
2
- VERSION = '0.1.1alpha'
2
+ VERSION = '0.2.0alpha'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comment_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1alpha
4
+ version: 0.2.0alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armando Alejandre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-11 00:00:00.000000000 Z
11
+ date: 2019-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails