acts_as_commentable_more 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/acts_as_commentable_more.rb +5 -2
- data/lib/{comment_methods.rb → acts_as_commentable_more/comment_methods.rb} +0 -0
- data/lib/acts_as_commentable_more/commentable_methods.rb +64 -0
- data/lib/acts_as_commentable_more/helpers/comment/callbacks_helper.rb +59 -0
- data/lib/acts_as_commentable_more/helpers/comment/methods_helper.rb +44 -0
- data/lib/acts_as_commentable_more/helpers/post/associations_helper.rb +30 -0
- data/lib/acts_as_commentable_more/helpers/post/methods_helper.rb +18 -0
- data/lib/acts_as_commentable_more/helpers/post/scopes_helper.rb +19 -0
- data/lib/acts_as_commentable_more/version.rb +1 -1
- data/lib/generators/commentable/templates/comment.rb +1 -1
- data/test/dummy/spec/models/letter_spec.rb +2 -1
- data/test/dummy/spec/models/main_model_spec.rb +5 -0
- data/test/dummy/spec/models/note_custom_asso_name_spec.rb +2 -1
- data/test/dummy/spec/models/note_spec.rb +2 -1
- data/test/dummy/spec/models/post_custom_asso_name_spec.rb +1 -1
- data/test/dummy/spec/models/post_disable_cache_spec.rb +5 -0
- data/test/dummy/spec/models/post_spec.rb +2 -1
- data/test/dummy/spec/models/topic_spec.rb +1 -1
- metadata +13 -165
- data/.coveralls.yml +0 -1
- data/.gitignore +0 -48
- data/.travis.yml +0 -22
- data/CHANGELOG.md +0 -12
- data/Gemfile +0 -40
- data/Gemfile.lock +0 -212
- data/LICENSE +0 -22
- data/README.md +0 -125
- data/acts_as_commentable_more.gemspec +0 -36
- data/lib/commentable_methods.rb +0 -118
- data/test/acts_as_commentable_more_test.rb +0 -7
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -17
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/admin.rb +0 -2
- data/test/dummy/app/models/comment.rb +0 -17
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/custom_comment.rb +0 -17
- data/test/dummy/app/models/letter.rb +0 -3
- data/test/dummy/app/models/note.rb +0 -3
- data/test/dummy/app/models/note_custom_asso_name.rb +0 -3
- data/test/dummy/app/models/post.rb +0 -4
- data/test/dummy/app/models/post_custom_asso_name.rb +0 -5
- data/test/dummy/app/models/topic.rb +0 -3
- data/test/dummy/app/models/user.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -35
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.travis.yml +0 -18
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -78
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/db/migrate/20150113045806_create_posts.rb +0 -9
- data/test/dummy/db/migrate/20150113045817_create_admins.rb +0 -9
- data/test/dummy/db/migrate/20150113045831_create_users.rb +0 -9
- data/test/dummy/db/migrate/20150113065948_create_notes.rb +0 -9
- data/test/dummy/db/migrate/20150113074249_create_topics.rb +0 -9
- data/test/dummy/db/migrate/20150114052120_create_letters.rb +0 -9
- data/test/dummy/db/migrate/20150114100411_create_comments.rb +0 -18
- data/test/dummy/db/migrate/20150114100422_create_custom_comments.rb +0 -18
- data/test/dummy/db/migrate/20150115094241_create_post_custom_asso_names.rb +0 -9
- data/test/dummy/db/migrate/20150115100013_create_note_custom_asso_names.rb +0 -9
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/spec/acts_as_commentable_more_spec.rb +0 -275
- data/test/dummy/spec/factories/admins.rb +0 -7
- data/test/dummy/spec/factories/comments.rb +0 -7
- data/test/dummy/spec/factories/custom_comments.rb +0 -7
- data/test/dummy/spec/factories/letters.rb +0 -7
- data/test/dummy/spec/factories/note_custom_asso_names.rb +0 -7
- data/test/dummy/spec/factories/notes.rb +0 -7
- data/test/dummy/spec/factories/post_custom_asso_names.rb +0 -7
- data/test/dummy/spec/factories/posts.rb +0 -7
- data/test/dummy/spec/factories/topics.rb +0 -7
- data/test/dummy/spec/factories/users.rb +0 -7
- data/test/dummy/spec/rails_helper.rb +0 -61
- data/test/dummy/spec/spec_helper.rb +0 -85
- data/test/test_helper.rb +0 -16
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
repo_token: UcUDq2TUR052ZfBRowsdMHTo1n4pF1uZ7
|
data/.gitignore
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
|
2
|
-
.bundle/
|
3
|
-
log/*.log
|
4
|
-
pkg/
|
5
|
-
test/dummy/db/*.sqlite3
|
6
|
-
test/dummy/db/*.sqlite3-journal
|
7
|
-
test/dummy/log/*.log
|
8
|
-
test/dummy/tmp/
|
9
|
-
test/dummy/.sass-cache
|
10
|
-
test/dummy/config/database.yml
|
11
|
-
test/dummy/db/schema.rb
|
12
|
-
|
13
|
-
test/dummy/coverage
|
14
|
-
|
15
|
-
*.rbc
|
16
|
-
capybara-*.html
|
17
|
-
.rspec
|
18
|
-
/log
|
19
|
-
/tmp
|
20
|
-
/db/*.sqlite3
|
21
|
-
/public/system
|
22
|
-
/coverage/
|
23
|
-
/spec/tmp
|
24
|
-
**.orig
|
25
|
-
rerun.txt
|
26
|
-
pickle-email-*.html
|
27
|
-
|
28
|
-
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
29
|
-
test/dummy/config/initializers/secret_token.rb
|
30
|
-
ctest/dummy/onfig/secrets.yml
|
31
|
-
|
32
|
-
## Environment normalisation:
|
33
|
-
/.bundle
|
34
|
-
/vendor/bundle
|
35
|
-
|
36
|
-
# these should all be checked in to normalise the environment:
|
37
|
-
# Gemfile.lock, .ruby-version, .ruby-gemset
|
38
|
-
|
39
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
40
|
-
.rvmrc
|
41
|
-
|
42
|
-
# if using bower-rails ignore default bower_components path bower.json files
|
43
|
-
/vendor/assets/bower_components
|
44
|
-
*.bowerrc
|
45
|
-
bower.json
|
46
|
-
|
47
|
-
# ignore coverage result file
|
48
|
-
test/dummy/coverage/.resultset.json
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.0.0
|
4
|
-
env: DB=postgres
|
5
|
-
|
6
|
-
sudo: true
|
7
|
-
|
8
|
-
gemfile: Gemfile
|
9
|
-
|
10
|
-
env: DB=postgresql
|
11
|
-
|
12
|
-
before_script:
|
13
|
-
- cd test/dummy
|
14
|
-
- cp config/database.travis.yml config/database.yml
|
15
|
-
- bundle install
|
16
|
-
- psql -c 'create database strano_test' -U postgres
|
17
|
-
- bundle exec rake db:create RAILS_ENV=test
|
18
|
-
- bundle exec rake db:migrate RAILS_ENV=test
|
19
|
-
- bundle exec rake db:test:prepare
|
20
|
-
|
21
|
-
script: bundle exec rspec
|
22
|
-
|
data/CHANGELOG.md
DELETED
data/Gemfile
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Declare your gem's dependencies in acts_as_commentable_more.gemspec.
|
4
|
-
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
-
# development dependencies will be added by default to the :development group.
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
# Declare any dependencies that are still in development here instead of in
|
9
|
-
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
-
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
-
# your gem to rubygems.org.
|
12
|
-
|
13
|
-
# To use debugger
|
14
|
-
# gem 'debugger'
|
15
|
-
|
16
|
-
gem "codeclimate-test-reporter", group: :test, require: nil
|
17
|
-
|
18
|
-
group :development do
|
19
|
-
gem 'bullet', '4.13.2'
|
20
|
-
gem 'spring', '1.1.3'
|
21
|
-
gem 'mina', '0.3.0'
|
22
|
-
gem 'hirb', '0.7.2'
|
23
|
-
gem 'better_errors', '2.0.0'
|
24
|
-
# gem 'debugger'
|
25
|
-
end
|
26
|
-
|
27
|
-
group :development, :test do
|
28
|
-
gem 'rspec-rails', '3.1.0'
|
29
|
-
gem 'capybara', '2.4.3'
|
30
|
-
gem 'shoulda-matchers', '2.7.0', require: false
|
31
|
-
gem 'guard-rspec', '4.3.1'
|
32
|
-
gem 'simplecov', '0.9.0', require: false
|
33
|
-
gem 'spring-commands-rspec', '1.0.2'
|
34
|
-
gem 'factory_girl_rails', '4.4.1'
|
35
|
-
gem 'coveralls', require: false
|
36
|
-
end
|
37
|
-
|
38
|
-
group :test do
|
39
|
-
# gem 'rspec-sidekiq'
|
40
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,212 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
acts_as_commentable_more (1.1.0)
|
5
|
-
rails (~> 4.1.8)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
actionmailer (4.1.9)
|
11
|
-
actionpack (= 4.1.9)
|
12
|
-
actionview (= 4.1.9)
|
13
|
-
mail (~> 2.5, >= 2.5.4)
|
14
|
-
actionpack (4.1.9)
|
15
|
-
actionview (= 4.1.9)
|
16
|
-
activesupport (= 4.1.9)
|
17
|
-
rack (~> 1.5.2)
|
18
|
-
rack-test (~> 0.6.2)
|
19
|
-
actionview (4.1.9)
|
20
|
-
activesupport (= 4.1.9)
|
21
|
-
builder (~> 3.1)
|
22
|
-
erubis (~> 2.7.0)
|
23
|
-
activemodel (4.1.9)
|
24
|
-
activesupport (= 4.1.9)
|
25
|
-
builder (~> 3.1)
|
26
|
-
activerecord (4.1.9)
|
27
|
-
activemodel (= 4.1.9)
|
28
|
-
activesupport (= 4.1.9)
|
29
|
-
arel (~> 5.0.0)
|
30
|
-
activesupport (4.1.9)
|
31
|
-
i18n (~> 0.6, >= 0.6.9)
|
32
|
-
json (~> 1.7, >= 1.7.7)
|
33
|
-
minitest (~> 5.1)
|
34
|
-
thread_safe (~> 0.1)
|
35
|
-
tzinfo (~> 1.1)
|
36
|
-
arel (5.0.1.20140414130214)
|
37
|
-
better_errors (2.0.0)
|
38
|
-
coderay (>= 1.0.0)
|
39
|
-
erubis (>= 2.6.6)
|
40
|
-
rack (>= 0.9.0)
|
41
|
-
builder (3.2.2)
|
42
|
-
bullet (4.13.2)
|
43
|
-
activesupport (>= 3.0.0)
|
44
|
-
uniform_notifier (>= 1.6.0)
|
45
|
-
capybara (2.4.3)
|
46
|
-
mime-types (>= 1.16)
|
47
|
-
nokogiri (>= 1.3.3)
|
48
|
-
rack (>= 1.0.0)
|
49
|
-
rack-test (>= 0.5.4)
|
50
|
-
xpath (~> 2.0)
|
51
|
-
celluloid (0.16.0)
|
52
|
-
timers (~> 4.0.0)
|
53
|
-
codeclimate-test-reporter (0.4.5)
|
54
|
-
simplecov (>= 0.7.1, < 1.0.0)
|
55
|
-
coderay (1.1.0)
|
56
|
-
coveralls (0.7.1)
|
57
|
-
multi_json (~> 1.3)
|
58
|
-
rest-client
|
59
|
-
simplecov (>= 0.7)
|
60
|
-
term-ansicolor
|
61
|
-
thor
|
62
|
-
diff-lcs (1.2.5)
|
63
|
-
docile (1.1.5)
|
64
|
-
erubis (2.7.0)
|
65
|
-
factory_girl (4.4.0)
|
66
|
-
activesupport (>= 3.0.0)
|
67
|
-
factory_girl_rails (4.4.1)
|
68
|
-
factory_girl (~> 4.4.0)
|
69
|
-
railties (>= 3.0.0)
|
70
|
-
ffi (1.9.6)
|
71
|
-
formatador (0.2.5)
|
72
|
-
guard (2.10.5)
|
73
|
-
formatador (>= 0.2.4)
|
74
|
-
listen (~> 2.7)
|
75
|
-
lumberjack (~> 1.0)
|
76
|
-
nenv (~> 0.1)
|
77
|
-
pry (>= 0.9.12)
|
78
|
-
thor (>= 0.18.1)
|
79
|
-
guard-rspec (4.3.1)
|
80
|
-
guard (~> 2.1)
|
81
|
-
rspec (>= 2.14, < 4.0)
|
82
|
-
hike (1.2.3)
|
83
|
-
hirb (0.7.2)
|
84
|
-
hitimes (1.2.2)
|
85
|
-
i18n (0.7.0)
|
86
|
-
json (1.8.2)
|
87
|
-
listen (2.8.4)
|
88
|
-
celluloid (>= 0.15.2)
|
89
|
-
rb-fsevent (>= 0.9.3)
|
90
|
-
rb-inotify (>= 0.9)
|
91
|
-
lumberjack (1.0.9)
|
92
|
-
mail (2.6.3)
|
93
|
-
mime-types (>= 1.16, < 3)
|
94
|
-
method_source (0.8.2)
|
95
|
-
mime-types (2.4.3)
|
96
|
-
mina (0.3.0)
|
97
|
-
open4
|
98
|
-
rake
|
99
|
-
mini_portile (0.6.1)
|
100
|
-
minitest (5.5.1)
|
101
|
-
multi_json (1.10.1)
|
102
|
-
nenv (0.1.1)
|
103
|
-
netrc (0.10.2)
|
104
|
-
nokogiri (1.6.5)
|
105
|
-
mini_portile (~> 0.6.0)
|
106
|
-
open4 (1.3.4)
|
107
|
-
pg (0.18.1)
|
108
|
-
pry (0.10.1)
|
109
|
-
coderay (~> 1.1.0)
|
110
|
-
method_source (~> 0.8.1)
|
111
|
-
slop (~> 3.4)
|
112
|
-
rack (1.5.2)
|
113
|
-
rack-test (0.6.3)
|
114
|
-
rack (>= 1.0)
|
115
|
-
rails (4.1.9)
|
116
|
-
actionmailer (= 4.1.9)
|
117
|
-
actionpack (= 4.1.9)
|
118
|
-
actionview (= 4.1.9)
|
119
|
-
activemodel (= 4.1.9)
|
120
|
-
activerecord (= 4.1.9)
|
121
|
-
activesupport (= 4.1.9)
|
122
|
-
bundler (>= 1.3.0, < 2.0)
|
123
|
-
railties (= 4.1.9)
|
124
|
-
sprockets-rails (~> 2.0)
|
125
|
-
railties (4.1.9)
|
126
|
-
actionpack (= 4.1.9)
|
127
|
-
activesupport (= 4.1.9)
|
128
|
-
rake (>= 0.8.7)
|
129
|
-
thor (>= 0.18.1, < 2.0)
|
130
|
-
rake (10.4.2)
|
131
|
-
rb-fsevent (0.9.4)
|
132
|
-
rb-inotify (0.9.5)
|
133
|
-
ffi (>= 0.5.0)
|
134
|
-
rest-client (1.7.2)
|
135
|
-
mime-types (>= 1.16, < 3.0)
|
136
|
-
netrc (~> 0.7)
|
137
|
-
rspec (3.1.0)
|
138
|
-
rspec-core (~> 3.1.0)
|
139
|
-
rspec-expectations (~> 3.1.0)
|
140
|
-
rspec-mocks (~> 3.1.0)
|
141
|
-
rspec-core (3.1.7)
|
142
|
-
rspec-support (~> 3.1.0)
|
143
|
-
rspec-expectations (3.1.2)
|
144
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
145
|
-
rspec-support (~> 3.1.0)
|
146
|
-
rspec-mocks (3.1.3)
|
147
|
-
rspec-support (~> 3.1.0)
|
148
|
-
rspec-rails (3.1.0)
|
149
|
-
actionpack (>= 3.0)
|
150
|
-
activesupport (>= 3.0)
|
151
|
-
railties (>= 3.0)
|
152
|
-
rspec-core (~> 3.1.0)
|
153
|
-
rspec-expectations (~> 3.1.0)
|
154
|
-
rspec-mocks (~> 3.1.0)
|
155
|
-
rspec-support (~> 3.1.0)
|
156
|
-
rspec-support (3.1.2)
|
157
|
-
shoulda-matchers (2.7.0)
|
158
|
-
activesupport (>= 3.0.0)
|
159
|
-
simplecov (0.9.0)
|
160
|
-
docile (~> 1.1.0)
|
161
|
-
multi_json
|
162
|
-
simplecov-html (~> 0.8.0)
|
163
|
-
simplecov-html (0.8.0)
|
164
|
-
slop (3.6.0)
|
165
|
-
spring (1.1.3)
|
166
|
-
spring-commands-rspec (1.0.2)
|
167
|
-
spring (>= 0.9.1)
|
168
|
-
sprockets (2.12.3)
|
169
|
-
hike (~> 1.2)
|
170
|
-
multi_json (~> 1.0)
|
171
|
-
rack (~> 1.0)
|
172
|
-
tilt (~> 1.1, != 1.3.0)
|
173
|
-
sprockets-rails (2.2.2)
|
174
|
-
actionpack (>= 3.0)
|
175
|
-
activesupport (>= 3.0)
|
176
|
-
sprockets (>= 2.8, < 4.0)
|
177
|
-
term-ansicolor (1.3.0)
|
178
|
-
tins (~> 1.0)
|
179
|
-
thor (0.19.1)
|
180
|
-
thread_safe (0.3.4)
|
181
|
-
tilt (1.4.1)
|
182
|
-
timers (4.0.1)
|
183
|
-
hitimes
|
184
|
-
tins (1.3.3)
|
185
|
-
tzinfo (1.2.2)
|
186
|
-
thread_safe (~> 0.1)
|
187
|
-
uniform_notifier (1.6.2)
|
188
|
-
xpath (2.0.0)
|
189
|
-
nokogiri (~> 1.3)
|
190
|
-
|
191
|
-
PLATFORMS
|
192
|
-
ruby
|
193
|
-
|
194
|
-
DEPENDENCIES
|
195
|
-
acts_as_commentable_more!
|
196
|
-
better_errors (= 2.0.0)
|
197
|
-
bullet (= 4.13.2)
|
198
|
-
capybara (= 2.4.3)
|
199
|
-
codeclimate-test-reporter
|
200
|
-
coveralls
|
201
|
-
factory_girl_rails (= 4.4.1)
|
202
|
-
guard-rspec (= 4.3.1)
|
203
|
-
hirb (= 0.7.2)
|
204
|
-
mina (= 0.3.0)
|
205
|
-
pg
|
206
|
-
rake
|
207
|
-
rspec
|
208
|
-
rspec-rails (= 3.1.0)
|
209
|
-
shoulda-matchers (= 2.7.0)
|
210
|
-
simplecov (= 0.9.0)
|
211
|
-
spring (= 1.1.3)
|
212
|
-
spring-commands-rspec (= 1.0.2)
|
data/LICENSE
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 PiYa
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
22
|
-
|
data/README.md
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
# ActsAsCommentableMore
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/acts_as_commentable_more.svg)](http://badge.fury.io/rb/acts_as_commentable_more)
|
4
|
-
[![Build Status](https://travis-ci.org/piya23300/acts_as_commentable_more.svg)](https://travis-ci.org/piya23300/acts_as_commentable_more)
|
5
|
-
[![Dependency Status](https://gemnasium.com/piya23300/acts_as_commentable_more.svg)](https://gemnasium.com/piya23300/acts_as_commentable_more)
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/piya23300/acts_as_commentable_more/badge.svg)](https://coveralls.io/r/piya23300/acts_as_commentable_more)
|
7
|
-
|
8
|
-
---
|
9
|
-
## Thank you
|
10
|
-
acts_as_commentable_more develops from [acts_as_commentable](https://github.com/jackdempsey/acts_as_commentable).
|
11
|
-
|
12
|
-
Thank you very much for way and inspiration.
|
13
|
-
|
14
|
-
### Generator
|
15
|
-
|
16
|
-
Generate model and migration
|
17
|
-
```ruby
|
18
|
-
rails generate commentable your_model_name
|
19
|
-
```
|
20
|
-
---
|
21
|
-
|
22
|
-
### Basic Usege
|
23
|
-
### Setting
|
24
|
-
Model would like to have commentable.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
class Post < ActiveRecord::Base
|
28
|
-
acts_as_commentable # default options types: [:comment], options: { class_name: 'Comment', as: :commentable }, as: :comments
|
29
|
-
end
|
30
|
-
```
|
31
|
-
|
32
|
-
```ruby
|
33
|
-
post = Post.create #<Post>
|
34
|
-
|
35
|
-
#get all comments of post
|
36
|
-
comments = post.comments #<ActiveRecord::Associations::CollectionProxy []>
|
37
|
-
|
38
|
-
#create comment of post
|
39
|
-
comment = post.creates_comments(message: 'new message') #<Comment>
|
40
|
-
comment = post.comments.create(message: 'new message') #<Comment>
|
41
|
-
|
42
|
-
#get owner comment
|
43
|
-
user = User.create
|
44
|
-
|
45
|
-
comment = post.creates_comments(message: 'I am user', user: user)
|
46
|
-
comment.user #<User>
|
47
|
-
|
48
|
-
```
|
49
|
-
|
50
|
-
### Any type of user in the same table
|
51
|
-
```ruby
|
52
|
-
post = Post.create #<Post>
|
53
|
-
|
54
|
-
admin = Admin.create
|
55
|
-
user = User.create
|
56
|
-
|
57
|
-
comment = post.creates_comments(message: 'I am user', user: user)
|
58
|
-
comment.user #<User>
|
59
|
-
|
60
|
-
comment = post.creates_comments(message: 'I am admin', user: admin)
|
61
|
-
comment.user #<Admin>
|
62
|
-
|
63
|
-
```
|
64
|
-
|
65
|
-
### Many type of comment
|
66
|
-
Setting Model
|
67
|
-
```ruby
|
68
|
-
class Post < ActiveRecord::Base
|
69
|
-
acts_as_commentable types: [:private, :public] # default options: { class_name: 'Comment', as: :commentable }, as: :comments
|
70
|
-
end
|
71
|
-
```
|
72
|
-
|
73
|
-
usage
|
74
|
-
```ruby
|
75
|
-
post = Post.create #<Post>
|
76
|
-
|
77
|
-
#get all private comments of post
|
78
|
-
private_comments = post.private_comments #[<Comment role: 'private'>]
|
79
|
-
|
80
|
-
#get all public comments of post
|
81
|
-
public_comments = post.public_comments #[<Comment role: 'public'>]
|
82
|
-
|
83
|
-
#get all comment of post
|
84
|
-
comments = post.all_comments #[<Comment>]
|
85
|
-
|
86
|
-
#create private comments
|
87
|
-
private_comment = post.creates_private_comments(message: 'private message') #<Comment role: 'private'>
|
88
|
-
|
89
|
-
#create public comments
|
90
|
-
public_comment = post.creates_public_comments(message: 'public message') #<Comment role: 'public'>
|
91
|
-
|
92
|
-
```
|
93
|
-
|
94
|
-
### Helper Method
|
95
|
-
|
96
|
-
#### For many types of comment
|
97
|
-
```ruby
|
98
|
-
post = Post.create #<Post>
|
99
|
-
|
100
|
-
private_comment = post.creates_private_comments #<Comment>
|
101
|
-
|
102
|
-
#Checked type of comment
|
103
|
-
private_comment.is_private? #true
|
104
|
-
private_comment.is_public? #false
|
105
|
-
|
106
|
-
#Changed type of comment
|
107
|
-
private_comment.to_public #not save
|
108
|
-
private_comment.to_public! #save
|
109
|
-
```
|
110
|
-
|
111
|
-
### Options
|
112
|
-
```ruby
|
113
|
-
acts_as_commentable types: [:show, :hide], options: { class_name: 'CustomComment', as: :custom_commentable }, as: notes
|
114
|
-
```
|
115
|
-
|
116
|
-
- type : type of comment #array
|
117
|
-
- options : association options #hash
|
118
|
-
- class_name : class name of comment
|
119
|
-
- as : polymorephic name
|
120
|
-
- as : name of association
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
## LICENSE
|
125
|
-
This project rocks and uses MIT-LICENSE.
|