refactors voting implementation [#25]

This commit is contained in:
rgarcia
2015-08-05 12:12:56 +02:00
parent cce6ca2fb9
commit 91b52ad8d2
9 changed files with 31 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
class CommentsController < ApplicationController
before_action :authenticate_user!
before_action :set_debate, :set_parent
before_action :set_debate, :set_parent, only: :create
respond_to :html, :js
def create
@@ -10,6 +10,12 @@ class CommentsController < ApplicationController
respond_with @comment
end
def vote
@comment = Comment.find(params[:id])
@comment.vote_by(voter: current_user, vote: params[:value])
respond_with @comment
end
private
def comment_params
params.require(:comments).permit(:commentable_type, :commentable_id, :body)