acts_as_votable 0.5.0 → 0.9.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 +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +25 -0
- data/Gemfile +14 -1
- data/README.markdown +243 -143
- data/Rakefile +8 -0
- data/acts_as_votable.gemspec +1 -6
- data/lib/acts_as_votable/extenders/controller.rb +19 -0
- data/lib/acts_as_votable/version.rb +1 -1
- data/lib/acts_as_votable/votable.rb +118 -44
- data/lib/acts_as_votable/vote.rb +8 -6
- data/lib/acts_as_votable/voter.rb +19 -20
- data/lib/acts_as_votable.rb +5 -0
- data/lib/generators/acts_as_votable/migration/migration_generator.rb +2 -2
- data/lib/generators/acts_as_votable/migration/templates/active_record/migration.rb +6 -2
- data/spec/shared_example/votable_model_spec.rb +393 -0
- data/spec/shared_example/voter_model_spec.rb +279 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/votable_spec.rb +6 -277
- data/spec/votable_voter_spec.rb +20 -0
- data/spec/voter_spec.rb +6 -289
- metadata +21 -42
- data/Gemfile.lock +0 -104
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b8402806ab189425b71b1d24d2081123e6bffc1
|
4
|
+
data.tar.gz: 48de253feb1e0df3ef42cd798faaaf8f91f36b47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7189eeb6505d6394bb090d58618d23ee13e36e6512f0416a15bf984c489e0775952680b748cadc054bd4948260184ac4a457ef6dee3b34f279561245adb2213e
|
7
|
+
data.tar.gz: 0fd78166628e72e3c77b8b5c8b8ba0028aa3069afb217816324c470ce6cc0c5a809431fcf47a800e440bbcb49020778e54f6f082698321357ded582081f488b0
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.8.7
|
4
|
+
- 1.9.2
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1.0
|
8
|
+
env:
|
9
|
+
- "RAILS_VERSION=3.0.0"
|
10
|
+
- "RAILS_VERSION=3.1.0"
|
11
|
+
- "RAILS_VERSION=3.2.0"
|
12
|
+
- "RAILS_VERSION=4.0.0"
|
13
|
+
- "RAILS_VERSION=4.1.0"
|
14
|
+
matrix:
|
15
|
+
exclude:
|
16
|
+
- rvm: 1.8.7
|
17
|
+
env: "RAILS_VERSION=4.0.0"
|
18
|
+
- rvm: 1.9.2
|
19
|
+
env: "RAILS_VERSION=4.0.0"
|
20
|
+
- rvm: 1.8.7
|
21
|
+
env: "RAILS_VERSION=4.1.0"
|
22
|
+
- rvm: 1.9.2
|
23
|
+
env: "RAILS_VERSION=4.1.0"
|
24
|
+
- rvm: 1.9.3
|
25
|
+
env: "RAILS_VERSION=4.1.0"
|
data/Gemfile
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in acts_as_votable.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
rails_version = ENV['RAILS_VERSION'] || 'default'
|
7
|
+
|
8
|
+
rails = case rails_version
|
9
|
+
when 'master'
|
10
|
+
{ :github => 'rails/rails'}
|
11
|
+
when 'default'
|
12
|
+
'~> 3.2.0'
|
13
|
+
else
|
14
|
+
"~> #{rails_version}"
|
15
|
+
end
|
16
|
+
|
17
|
+
gem 'rails', rails
|
data/README.markdown
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Acts As Votable (aka Acts As Likeable)
|
2
2
|
|
3
|
+
[](https://travis-ci.org/ryanto/acts_as_votable)
|
4
|
+
|
3
5
|
Acts As Votable is a Ruby Gem specifically written for Rails/ActiveRecord models.
|
4
6
|
The main goals of this gem are:
|
5
7
|
|
@@ -11,11 +13,20 @@ The main goals of this gem are:
|
|
11
13
|
|
12
14
|
## Installation
|
13
15
|
|
14
|
-
### Rails
|
16
|
+
### Supported Ruby and Rails versions
|
17
|
+
|
18
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3
|
19
|
+
* Ruby 2.0.0, 2.1.0
|
20
|
+
* Rails 3.0, 3.1, 3.2
|
21
|
+
* Rails 4.0, 4.1+
|
22
|
+
|
23
|
+
### Install
|
15
24
|
|
16
25
|
Just add the following to your Gemfile.
|
17
26
|
|
18
|
-
|
27
|
+
```ruby
|
28
|
+
gem 'acts_as_votable', '~> 0.9.0'
|
29
|
+
```
|
19
30
|
|
20
31
|
And follow that up with a ``bundle install``.
|
21
32
|
|
@@ -35,81 +46,92 @@ caching section of this document for more information.
|
|
35
46
|
|
36
47
|
### Votable Models
|
37
48
|
|
38
|
-
|
39
|
-
|
40
|
-
|
49
|
+
```ruby
|
50
|
+
class Post < ActiveRecord::Base
|
51
|
+
acts_as_votable
|
52
|
+
end
|
41
53
|
|
42
|
-
|
43
|
-
|
54
|
+
@post = Post.new(:name => 'my post!')
|
55
|
+
@post.save
|
44
56
|
|
45
|
-
|
46
|
-
|
57
|
+
@post.liked_by @user
|
58
|
+
@post.votes_for.size # => 1
|
59
|
+
```
|
47
60
|
|
48
61
|
### Like/Dislike Yes/No Up/Down
|
49
62
|
|
50
63
|
Here are some voting examples. All of these calls are valid and acceptable. The
|
51
64
|
more natural calls are the first few examples.
|
52
65
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
66
|
+
```ruby
|
67
|
+
@post.liked_by @user1
|
68
|
+
@post.downvote_from @user2
|
69
|
+
@post.vote_by :voter => @user3
|
70
|
+
@post.vote_by :voter => @user4, :vote => 'bad'
|
71
|
+
@post.vote_by :voter => @user5, :vote => 'like'
|
72
|
+
```
|
58
73
|
|
74
|
+
By default all votes are positive, so `@user3` has cast a 'good' vote for `@post`.
|
59
75
|
|
60
|
-
|
76
|
+
`@user1`, `@user3`, and `@user5` all voted in favor of `@post`.
|
61
77
|
|
62
|
-
|
63
|
-
|
64
|
-
@user2 and @user4 on the other had has voted against @post.
|
78
|
+
`@user2` and `@user4` on the other had has voted against `@post`.
|
65
79
|
|
66
80
|
|
67
81
|
Just about any word works for casting a vote in favor or against post. Up/Down,
|
68
|
-
Like/Dislike, Positive/Negative... the list goes on-and-on. Boolean flags
|
69
|
-
|
82
|
+
Like/Dislike, Positive/Negative... the list goes on-and-on. Boolean flags `true` and
|
83
|
+
`false` are also applicable.
|
70
84
|
|
71
85
|
Revisiting the previous example of code.
|
72
86
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
87
|
+
```ruby
|
88
|
+
# positive votes
|
89
|
+
@post.liked_by @user1
|
90
|
+
@post.vote_by :voter => @user3
|
91
|
+
@post.vote_by :voter => @user5, :vote => 'like'
|
77
92
|
|
78
|
-
|
79
|
-
|
80
|
-
|
93
|
+
# negative votes
|
94
|
+
@post.downvote_from @user2
|
95
|
+
@post.vote_by :voter => @user2, :vote => 'bad'
|
81
96
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
# tally them up!
|
98
|
+
@post.votes_for.size # => 5
|
99
|
+
@post.get_likes.size # => 3
|
100
|
+
@post.get_upvotes.size # => 3
|
101
|
+
@post.get_dislikes.size # => 2
|
102
|
+
@post.get_downvotes.size # => 2
|
103
|
+
```
|
88
104
|
|
89
105
|
Active Record scopes are provided to make life easier.
|
90
106
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
107
|
+
```ruby
|
108
|
+
@post.votes_for.up.by_type(User)
|
109
|
+
@post.votes_for.down
|
110
|
+
@user1.votes.up
|
111
|
+
@user1.votes.down
|
112
|
+
@user1.votes.up.by_type(Post)
|
113
|
+
```
|
96
114
|
|
97
115
|
Once scoping is complete, you can also trigger a get for the
|
98
116
|
voter/votable
|
99
117
|
|
100
|
-
|
101
|
-
|
118
|
+
```ruby
|
119
|
+
@post.votes_for.up.by_type(User).voters
|
120
|
+
@post.votes_for.down.by_type(User).voters
|
102
121
|
|
103
|
-
|
104
|
-
|
122
|
+
@user.votes.up.for_type(Post).votables
|
123
|
+
@user.votes.up.votables
|
124
|
+
```
|
105
125
|
|
106
126
|
You can also 'unvote' a model to remove a previous vote.
|
107
127
|
|
108
|
-
|
109
|
-
|
128
|
+
```ruby
|
129
|
+
@post.liked_by @user1
|
130
|
+
@post.unliked_by @user1
|
110
131
|
|
111
|
-
|
112
|
-
|
132
|
+
@post.disliked_by @user1
|
133
|
+
@post.undisliked_by @user1
|
134
|
+
```
|
113
135
|
|
114
136
|
Unvoting works for both positive and negative votes.
|
115
137
|
|
@@ -117,124 +139,168 @@ Unvoting works for both positive and negative votes.
|
|
117
139
|
|
118
140
|
You can add an scope to your vote
|
119
141
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
142
|
+
```ruby
|
143
|
+
# positive votes
|
144
|
+
@post.liked_by @user1, :vote_scope => 'rank'
|
145
|
+
@post.vote_by :voter => @user3, :vote_scope => 'rank'
|
146
|
+
@post.vote_by :voter => @user5, :vote => 'like', :vote_scope => 'rank'
|
147
|
+
|
148
|
+
# negative votes
|
149
|
+
@post.downvote_from @user2, :vote_scope => 'rank'
|
150
|
+
@post.vote_by :voter => @user2, :vote => 'bad', :vote_scope => 'rank'
|
151
|
+
|
152
|
+
# tally them up!
|
153
|
+
@post.find_votes_for(:vote_scope => 'rank').size # => 5
|
154
|
+
@post.get_likes(:vote_scope => 'rank').size # => 3
|
155
|
+
@post.get_upvotes(:vote_scope => 'rank').size # => 3
|
156
|
+
@post.get_dislikes(:vote_scope => 'rank').size # => 2
|
157
|
+
@post.get_downvotes(:vote_scope => 'rank').size # => 2
|
158
|
+
|
159
|
+
# votable model can be voted under different scopes
|
160
|
+
# by the same user
|
161
|
+
@post.vote_by :voter => @user1, :vote_scope => 'week'
|
162
|
+
@post.vote_by :voter => @user1, :vote_scope => 'month'
|
163
|
+
|
164
|
+
@post.votes_for.size # => 2
|
165
|
+
@post.find_votes_for(:vote_scope => 'week').size # => 1
|
166
|
+
@post.find_votes_for(:vote_scope => 'month').size # => 1
|
167
|
+
```
|
168
|
+
### Adding weights to your votes
|
169
|
+
|
170
|
+
You can add weight to your vote. The default value is 1.
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
# positive votes
|
174
|
+
@post.liked_by @user1, :vote_weight => 1
|
175
|
+
@post.vote_by :voter => @user3, :vote_weight => 2
|
176
|
+
@post.vote_by :voter => @user5, :vote => 'like', :vote_scope => 'rank', :vote_weight => 3
|
177
|
+
|
178
|
+
# negative votes
|
179
|
+
@post.downvote_from @user2, :vote_scope => 'rank', :vote_weight => 1
|
180
|
+
@post.vote_by :voter => @user2, :vote => 'bad', :vote_scope => 'rank', :vote_weight => 3
|
181
|
+
|
182
|
+
# tally them up!
|
183
|
+
@post.find_votes_for(:vote_scope => 'rank').sum(:vote_weight) # => 6
|
184
|
+
@post.get_likes(:vote_scope => 'rank').sum(:vote_weight) # => 6
|
185
|
+
@post.get_upvotes(:vote_scope => 'rank').sum(:vote_weight) # => 6
|
186
|
+
@post.get_dislikes(:vote_scope => 'rank').sum(:vote_weight) # => 4
|
187
|
+
@post.get_downvotes(:vote_scope => 'rank').sum(:vote_weight) # => 4
|
188
|
+
```
|
144
189
|
|
145
190
|
### The Voter
|
146
191
|
|
147
|
-
You can have your voters
|
192
|
+
You can have your voters `acts_as_voter` to provide some reserve functionality.
|
148
193
|
|
149
|
-
|
150
|
-
|
151
|
-
|
194
|
+
```ruby
|
195
|
+
class User < ActiveRecord::Base
|
196
|
+
acts_as_voter
|
197
|
+
end
|
152
198
|
|
153
|
-
|
199
|
+
@user.likes @article
|
154
200
|
|
155
|
-
|
156
|
-
|
157
|
-
|
201
|
+
@article.votes.size # => 1
|
202
|
+
@article.likes.size # => 1
|
203
|
+
@article.dislikes.size # => 0
|
204
|
+
```
|
158
205
|
|
159
206
|
To check if a voter has voted on a model, you can use ``voted_for?``. You can
|
160
207
|
check how the voter voted by using ``voted_as_when_voted_for``.
|
161
208
|
|
162
|
-
|
163
|
-
|
164
|
-
|
209
|
+
```ruby
|
210
|
+
@user.likes @comment1
|
211
|
+
@user.up_votes @comment2
|
212
|
+
# user has not voted on @comment3
|
165
213
|
|
166
|
-
|
167
|
-
|
168
|
-
|
214
|
+
@user.voted_for? @comment1 # => true
|
215
|
+
@user.voted_for? @comment2 # => true
|
216
|
+
@user.voted_for? @comment3 # => false
|
169
217
|
|
170
|
-
|
171
|
-
|
172
|
-
|
218
|
+
@user.voted_as_when_voted_for @comment1 # => true, he liked it
|
219
|
+
@user.voted_as_when_voted_for @comment2 # => false, he didnt like it
|
220
|
+
@user.voted_as_when_voted_for @comment3 # => nil, he has yet to vote
|
221
|
+
```
|
173
222
|
|
174
223
|
You can also check whether the voter has voted up or down.
|
175
224
|
|
176
|
-
|
177
|
-
|
178
|
-
|
225
|
+
```ruby
|
226
|
+
@user.likes @comment1
|
227
|
+
@user.dislikes @comment2
|
228
|
+
# user has not voted on @comment3
|
179
229
|
|
180
|
-
|
181
|
-
|
230
|
+
@user.voted_up_on? @comment1 # => true
|
231
|
+
@user.voted_down_on? @comment1 # => false
|
182
232
|
|
183
|
-
|
184
|
-
|
233
|
+
@user.voted_down_on? @comment2 # => true
|
234
|
+
@user.voted_up_on? @comment2 # => false
|
185
235
|
|
186
|
-
|
187
|
-
|
236
|
+
@user.voted_up_on? @comment3 # => false
|
237
|
+
@user.voted_down_on? @comment3 # => false
|
238
|
+
```
|
188
239
|
|
189
|
-
Aliases for methods
|
240
|
+
Aliases for methods `voted_up_on?` and `voted_down_on?` are: `voted_up_for?`, `voted_down_for?`, `liked?` and `disliked?`.
|
190
241
|
|
191
242
|
Also, you can obtain a list of all the objects a user has voted for.
|
192
243
|
This returns the actual objects instead of instances of the Vote model.
|
193
244
|
All objects are eager loaded
|
194
245
|
|
195
|
-
|
246
|
+
```ruby
|
247
|
+
@user.find_voted_items
|
196
248
|
|
197
|
-
|
198
|
-
|
249
|
+
@user.find_up_voted_items
|
250
|
+
@user.find_liked_items
|
199
251
|
|
200
|
-
|
201
|
-
|
252
|
+
@user.find_down_voted_items
|
253
|
+
@user.find_disliked_items
|
254
|
+
```
|
202
255
|
|
203
256
|
Members of an individual model that a user has voted for can also be
|
204
257
|
displayed. The result is an ActiveRecord Relation.
|
205
258
|
|
206
|
-
|
259
|
+
```ruby
|
260
|
+
@user.get_voted Comment
|
207
261
|
|
208
|
-
|
262
|
+
@user.get_up_voted Comment
|
209
263
|
|
210
|
-
|
264
|
+
@user.get_down_voted Comment
|
265
|
+
```
|
211
266
|
|
212
267
|
### Registered Votes
|
213
268
|
|
214
269
|
Voters can only vote once per model. In this example the 2nd vote does not count
|
215
|
-
because
|
270
|
+
because `@user` has already voted for `@shoe`.
|
216
271
|
|
217
|
-
|
218
|
-
|
272
|
+
```ruby
|
273
|
+
@user.likes @shoe
|
274
|
+
@user.likes @shoe
|
219
275
|
|
220
|
-
|
221
|
-
|
276
|
+
@shoe.votes # => 1
|
277
|
+
@shoe.likes # => 1
|
278
|
+
```
|
222
279
|
|
223
|
-
To check if a vote counted, or registered, use vote_registered
|
280
|
+
To check if a vote counted, or registered, use `vote_registered?` on your model
|
224
281
|
after voting. For example:
|
225
282
|
|
226
|
-
|
227
|
-
|
283
|
+
```ruby
|
284
|
+
@hat.liked_by @user
|
285
|
+
@hat.vote_registered? # => true
|
286
|
+
|
287
|
+
@hat.liked_by => @user
|
288
|
+
@hat.vote_registered? # => false, because @user has already voted this way
|
228
289
|
|
229
|
-
|
230
|
-
|
290
|
+
@hat.disliked_by @user
|
291
|
+
@hat.vote_registered? # => true, because user changed their vote
|
231
292
|
|
232
|
-
|
233
|
-
|
293
|
+
@hat.votes.size # => 1
|
294
|
+
@hat.positives.size # => 0
|
295
|
+
@hat.negatives.size # => 1
|
296
|
+
```
|
234
297
|
|
235
|
-
|
236
|
-
|
237
|
-
|
298
|
+
To permit duplicates entries of a same voter, use option duplicate. Also notice that this
|
299
|
+
will limit some other methods that didn't deal with multiples votes, in this case, the last vote will be considered.
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
@hat.vote_by voter: @user, :duplicate => true
|
303
|
+
```
|
238
304
|
|
239
305
|
## Caching
|
240
306
|
|
@@ -242,40 +308,74 @@ To speed up perform you can add cache columns to your votable model's table. Th
|
|
242
308
|
columns will automatically be updated after each vote. For example, if we wanted
|
243
309
|
to speed up @post we would use the following migration:
|
244
310
|
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
311
|
+
```ruby
|
312
|
+
class AddCachedVotesToPosts < ActiveRecord::Migration
|
313
|
+
def self.up
|
314
|
+
add_column :posts, :cached_votes_total, :integer, :default => 0
|
315
|
+
add_column :posts, :cached_votes_score, :integer, :default => 0
|
316
|
+
add_column :posts, :cached_votes_up, :integer, :default => 0
|
317
|
+
add_column :posts, :cached_votes_down, :integer, :default => 0
|
318
|
+
add_column :posts, :cached_weighted_score, :integer, :default => 0
|
319
|
+
add_index :posts, :cached_votes_total
|
320
|
+
add_index :posts, :cached_votes_score
|
321
|
+
add_index :posts, :cached_votes_up
|
322
|
+
add_index :posts, :cached_votes_down
|
323
|
+
add_index :posts, :cached_weighted_score
|
324
|
+
|
325
|
+
# Uncomment this line to force caching of existing votes
|
326
|
+
# Post.find_each(&:update_cached_votes)
|
327
|
+
end
|
328
|
+
|
329
|
+
def self.down
|
330
|
+
remove_column :posts, :cached_votes_total
|
331
|
+
remove_column :posts, :cached_votes_score
|
332
|
+
remove_column :posts, :cached_votes_up
|
333
|
+
remove_column :posts, :cached_votes_down
|
334
|
+
remove_column :posts, :cached_weighted_score
|
335
|
+
end
|
336
|
+
end
|
337
|
+
```
|
264
338
|
|
265
339
|
## Testing
|
266
340
|
|
267
|
-
All tests follow the RSpec format and are located in the spec directory
|
341
|
+
All tests follow the RSpec format and are located in the spec directory.
|
342
|
+
They can be run with:
|
343
|
+
|
344
|
+
```
|
345
|
+
rake spec
|
346
|
+
```
|
347
|
+
|
348
|
+
## Changes
|
349
|
+
|
350
|
+
### Fixes for votable voter model
|
351
|
+
|
352
|
+
In version 0.8.0, there is bugs for a model that is both votable and voter.
|
353
|
+
Some name-conflicting methods are renamed:
|
354
|
+
+ Renamed Votable.votes to votes_for
|
355
|
+
+ Renamed Votable.vote to vote_by,
|
356
|
+
+ Removed Votable.vote_by alias (was an alias for :vote_up)
|
357
|
+
+ Renamed Votable.unvote_for to unvote_by
|
358
|
+
+ Renamed Votable.find_votes to find_votes_for
|
359
|
+
+ Renamed Votable.up_votes to get_upvotes
|
360
|
+
+ and its aliases :get_true_votes, :get_ups, :get_upvotes, :get_likes, :get_positives, :get_for_votes
|
361
|
+
+ Renamed Votable.down_votes to get_downvotes
|
362
|
+
+ and its aliases :get_false_votes, :get_downs, :get_downvotes, :get_dislikes, :get_negatives
|
363
|
+
|
364
|
+
|
365
|
+
## License
|
366
|
+
|
367
|
+
Acts as votable is released under the [MIT
|
368
|
+
License](http://www.opensource.org/licenses/MIT).
|
268
369
|
|
269
370
|
## TODO
|
270
371
|
|
271
372
|
- Pass in a block of options when creating acts_as. Allow for things
|
272
373
|
like disabling the aliasing
|
273
374
|
|
274
|
-
- Smarter language syntax. Example:
|
275
|
-
that the user likes, while
|
375
|
+
- Smarter language syntax. Example: `@user.likes` will return all of the votables
|
376
|
+
that the user likes, while `@user.likes @model` will cast a vote for @model by
|
276
377
|
@user.
|
277
378
|
|
278
|
-
- Need to test a model that is votable as well as a voter
|
279
379
|
|
280
380
|
- The aliased methods are referred to by using the terms 'up/down' and/or
|
281
381
|
'true/false'. Need to come up with guidelines for naming these methods.
|
data/Rakefile
CHANGED
data/acts_as_votable.gemspec
CHANGED
@@ -19,11 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
|
23
|
-
|
24
22
|
s.add_development_dependency "rspec"
|
25
|
-
s.add_development_dependency "sqlite3"
|
26
|
-
|
27
|
-
s.add_dependency "rails", '>=3.0.0'
|
28
|
-
|
23
|
+
s.add_development_dependency "sqlite3", '1.3.7'
|
29
24
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ActsAsVotable
|
2
|
+
module Extenders
|
3
|
+
|
4
|
+
module Controller
|
5
|
+
|
6
|
+
def voter_params(params_object = params[:vote])
|
7
|
+
params_object.permit(:votable_id, :votable_type,
|
8
|
+
:voter_id, :voter_type,
|
9
|
+
:votable, :voter,
|
10
|
+
:vote_flag, :vote_scope)
|
11
|
+
end
|
12
|
+
|
13
|
+
def votable_params(params_object = params[:vote])
|
14
|
+
params_object.permit(:vote_registered)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|