refactors voting implementation [#25]
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user