rostra 0.1.15 → 0.1.16
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.
- data/app/controllers/rostra/base/answers_controller.rb +0 -1
- data/app/controllers/rostra/base/questions_controller.rb +1 -1
- data/app/models/vote.rb +9 -0
- data/app/views/rostra/answers/vote.js.erb +1 -1
- data/app/views/rostra/questions/index.html.erb +2 -2
- data/app/views/rostra/questions/vote.js.erb +1 -1
- data/app/views/rostra/shared/_votes.html.erb +1 -1
- data/db/migrate/20111106162542_add_votes_count_to_rostra_answers.rb +5 -0
- data/db/migrate/20111106164824_add_votes_count_to_rostra_questions.rb +5 -0
- data/lib/rostra/version.rb +1 -1
- data/lib/rostra.rb +1 -0
- metadata +4 -2
data/app/models/vote.rb
CHANGED
@@ -14,4 +14,13 @@ class Vote < ActiveRecord::Base
|
|
14
14
|
# Comment out the line below to allow multiple votes per user.
|
15
15
|
validates_uniqueness_of :voteable_id, :scope => [:voteable_type, :voter_type, :voter_id]
|
16
16
|
|
17
|
+
after_create :update_counter_cache
|
18
|
+
after_destroy :update_counter_cache
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def update_counter_cache
|
23
|
+
voteable.update_attribute(:votes_count, voteable.plusminus)
|
24
|
+
end
|
25
|
+
|
17
26
|
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
var selector = "#rostra_answer_<%= @answer.id%> .vote_wrapper";
|
2
|
-
$(selector).replaceWith('<%= escape_javascript(render(:
|
2
|
+
$(selector).replaceWith('<%= escape_javascript(render(partial: 'rostra/shared/votes', locals: {resource: @answer})) %>');
|
@@ -12,8 +12,8 @@
|
|
12
12
|
|
13
13
|
<div class="stats">
|
14
14
|
<div class="vote_count" title="Number of times this question was voted up">
|
15
|
-
<span class="count"><%= question.
|
16
|
-
<span class="type"><%= question.
|
15
|
+
<span class="count"><%= question.votes_count %></span>
|
16
|
+
<span class="type"><%= question.votes_count.abs == 1 ? 'vote' : 'votes' %></span>
|
17
17
|
</div>
|
18
18
|
<div class="answer_count" title="Number of times this question was answered">
|
19
19
|
<span class="count"><%= question.answer_count %></span>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
var selector = "#rostra_question_<%= @question.id%> .vote_wrapper";
|
1
|
+
var selector = "#rostra_question_<%= @question.id %> .vote_wrapper";
|
2
2
|
$(selector).replaceWith('<%= escape_javascript(render partial: 'rostra/shared/votes', locals: { resource: @question }) %>');
|
data/lib/rostra/version.rb
CHANGED
data/lib/rostra.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rostra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.16
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Cory Schires
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-11-
|
13
|
+
date: 2011-11-06 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -556,6 +556,8 @@ files:
|
|
556
556
|
- db/migrate/20111019162723_create_rostra_question_followings.rb
|
557
557
|
- db/migrate/20111024223022_add_send_email_notifications_to_question_followings.rb
|
558
558
|
- db/migrate/20111029214642_add_impressions_count_to_questions.rb
|
559
|
+
- db/migrate/20111106162542_add_votes_count_to_rostra_answers.rb
|
560
|
+
- db/migrate/20111106164824_add_votes_count_to_rostra_questions.rb
|
559
561
|
- lib/generators/rostra/install_generator.rb
|
560
562
|
- lib/generators/rostra/templates/app/helpers/rostra/application_helper.rb
|
561
563
|
- lib/generators/rostra/templates/config/initializers/rostra.rb
|