adds votes to debates [#9]

This commit is contained in:
rgarcia
2015-07-18 18:10:19 +02:00
parent b8e41551f9
commit e006549092
5 changed files with 69 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
class VotesController < ApplicationController
before_action :set_debate
before_action :authenticate_user!
def create
register_vote
notice = @debate.vote_registered? ? "Gracias por votar." : "Tu voto ya ha sido registrado."
redirect_to @debate, notice: notice
end
private
def set_debate
@debate = Debate.find(params[:debate_id])
end
def register_vote
@debate.vote_by voter: current_user, vote: params[:value]
end
end