digitalmoksha-acts_as_commentable 6.0.0 → 8.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 +4 -4
- data/README.rdoc +4 -22
- data/lib/commentable_methods.rb +12 -17
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 835ebde56a03a3628011fcc2eec83d7f5baa9fc5f63e6520362dfb5a648533de
|
|
4
|
+
data.tar.gz: 6c8290f6840b236cca2287aad23d980a4cd6a98e19d8ec7838f36863b6625233
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7fd6ece1a9d6245cecc225503c7cadd82aeb46c3f90777a67305416166059001f5488d00b784c7e53956320644055e9c28e33daae913e86668b18d38b30d9895
|
|
7
|
+
data.tar.gz: 257a0003a657260bb01cfea38e77517d375cbbb0cffbf3ffbea4f2f7e9690ef97e830b45e23581ba125b955dd5a17fcb3ffcb5c5e56980b079c718c636f5cb7e
|
data/README.rdoc
CHANGED
|
@@ -9,30 +9,12 @@ commentable models.
|
|
|
9
9
|
|
|
10
10
|
Add the following line to your Gemfile
|
|
11
11
|
|
|
12
|
-
=== Rails 4
|
|
13
|
-
|
|
14
12
|
gem 'acts_as_commentable'
|
|
15
13
|
|
|
16
|
-
=== Rails 3
|
|
17
|
-
|
|
18
|
-
gem 'acts_as_commentable', '3.0.1'
|
|
19
|
-
|
|
20
|
-
=== Rails 2
|
|
21
|
-
|
|
22
|
-
gem 'acts_as_commentable', git: 'git@github.com:jackdempsey/acts_as_commentable.git', branch: '2.x'
|
|
23
|
-
|
|
24
|
-
|
|
25
14
|
== Generator
|
|
26
15
|
|
|
27
|
-
|
|
28
|
-
=== Rails 3+
|
|
29
|
-
|
|
30
16
|
rails g comment
|
|
31
17
|
|
|
32
|
-
=== Rails 2
|
|
33
|
-
|
|
34
|
-
script/generate comment
|
|
35
|
-
|
|
36
18
|
Then migrate your database to add the comments model:
|
|
37
19
|
|
|
38
20
|
rake db:migrate
|
|
@@ -40,13 +22,13 @@ Then migrate your database to add the comments model:
|
|
|
40
22
|
== Usage
|
|
41
23
|
|
|
42
24
|
Make the desired ActiveRecord model act as commentable:
|
|
43
|
-
|
|
25
|
+
|
|
44
26
|
class Post < ActiveRecord::Base
|
|
45
27
|
acts_as_commentable
|
|
46
28
|
end
|
|
47
29
|
|
|
48
30
|
Add a comment to a model instance by adding the following to the controller:
|
|
49
|
-
|
|
31
|
+
|
|
50
32
|
commentable = Post.create
|
|
51
33
|
comment = commentable.comments.create
|
|
52
34
|
comment.title = "First comment."
|
|
@@ -55,12 +37,12 @@ Add a comment to a model instance by adding the following to the controller:
|
|
|
55
37
|
|
|
56
38
|
|
|
57
39
|
Fetch comments for the commentable model by adding the following to the view:
|
|
58
|
-
|
|
40
|
+
|
|
59
41
|
commentable = Post.find(1)
|
|
60
42
|
comments = commentable.comments.recent.limit(10).all
|
|
61
43
|
|
|
62
44
|
You can also add different types of comments to a model:
|
|
63
|
-
|
|
45
|
+
|
|
64
46
|
class Todo < ActiveRecord::Base
|
|
65
47
|
acts_as_commentable :public, :private
|
|
66
48
|
end
|
data/lib/commentable_methods.rb
CHANGED
|
@@ -15,23 +15,6 @@ module Juixe
|
|
|
15
15
|
send("define_role_based_inflection_#{Rails.version.first}", role)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def define_role_based_inflection_3(role)
|
|
19
|
-
has_many "#{role.to_s}_comments".to_sym,
|
|
20
|
-
has_many_options(role).merge(:conditions => { role: role.to_s })
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def define_role_based_inflection_4(role)
|
|
24
|
-
has_many "#{role.to_s}_comments".to_sym,
|
|
25
|
-
-> { where(role: role.to_s) },
|
|
26
|
-
has_many_options(role)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def define_role_based_inflection_5(role)
|
|
30
|
-
has_many "#{role.to_s}_comments".to_sym,
|
|
31
|
-
-> { where(role: role.to_s) },
|
|
32
|
-
has_many_options(role)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
18
|
def define_role_based_inflection_6(role)
|
|
36
19
|
if RUBY_VERSION.first >= '3'
|
|
37
20
|
has_many "#{role.to_s}_comments".to_sym,
|
|
@@ -56,6 +39,18 @@ module Juixe
|
|
|
56
39
|
end
|
|
57
40
|
end
|
|
58
41
|
|
|
42
|
+
def define_role_based_inflection_8(role)
|
|
43
|
+
if RUBY_VERSION.first >= '3'
|
|
44
|
+
has_many "#{role.to_s}_comments".to_sym,
|
|
45
|
+
-> { where(role: role.to_s) },
|
|
46
|
+
**has_many_options(role)
|
|
47
|
+
else
|
|
48
|
+
has_many "#{role.to_s}_comments".to_sym,
|
|
49
|
+
-> { where(role: role.to_s) },
|
|
50
|
+
has_many_options(role)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
59
54
|
|
|
60
55
|
def has_many_options(role)
|
|
61
56
|
{:class_name => "Comment",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: digitalmoksha-acts_as_commentable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cosmin Radoi, Jack Dempsey, Xelipe, Chris Eppstein
|
|
@@ -9,15 +9,15 @@ authors:
|
|
|
9
9
|
autorequire: acts_as_commentable
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: Plugin/gem that provides comment functionality
|
|
15
15
|
email: unknown@juixe.com
|
|
16
16
|
executables: []
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files:
|
|
19
|
-
- README.rdoc
|
|
20
19
|
- MIT-LICENSE
|
|
20
|
+
- README.rdoc
|
|
21
21
|
files:
|
|
22
22
|
- MIT-LICENSE
|
|
23
23
|
- README.rdoc
|
|
@@ -34,7 +34,6 @@ homepage: https://github.com/digitalmoksha/acts_as_commentable
|
|
|
34
34
|
licenses:
|
|
35
35
|
- MIT
|
|
36
36
|
metadata: {}
|
|
37
|
-
post_install_message:
|
|
38
37
|
rdoc_options: []
|
|
39
38
|
require_paths:
|
|
40
39
|
- lib
|
|
@@ -49,8 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
49
48
|
- !ruby/object:Gem::Version
|
|
50
49
|
version: '0'
|
|
51
50
|
requirements: []
|
|
52
|
-
rubygems_version:
|
|
53
|
-
signing_key:
|
|
51
|
+
rubygems_version: 4.0.11
|
|
54
52
|
specification_version: 3
|
|
55
53
|
summary: Plugin/gem that provides comment functionality
|
|
56
54
|
test_files: []
|