Sha256: c475dd78593ab032f26459888cbac0efd96f3a8e3e9012de446aa617aca46fb6
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
module Rostra class AnswersController < ApplicationController load_and_authorize_resource before_filter :fetch_question def vote if current_user.voted_for?(@answer) && params[:vote_type] == 'up' current_user.clear_votes(@answer) elsif current_user.voted_against?(@answer) && params[:vote_type] == 'down' current_user.clear_votes(@answer) else current_user.vote_exclusively_for(@answer) if params[:vote_type] == 'up' current_user.vote_exclusively_against(@answer) if params[:vote_type] == 'down' end respond_to do |format| format.html { redirect_to question_path(@question, anchor: "rostra_answer_#{@answer.id}") } format.js end end def create if @answer.save redirect_to question_path(@question, anchor: "rostra_answer_#{@answer.id}") else redirect_to question_path(@question, anchor: 'new_rostra_answer') end end def edit end def update if @answer.update_attributes(params[:answer]) redirect_to question_path(@question, anchor: "rostra_answer_#{@answer.id}") else render :edit end end private def fetch_question @question = Question.find(params[:question_id]) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rostra-0.0.3 | app/controllers/rostra/answers_controller.rb |
rostra-0.0.2 | app/controllers/rostra/answers_controller.rb |
rostra-0.0.1 | app/controllers/rostra/answers_controller.rb |