Sha256: 610d18f2983f7523c37d5be9bb0fb48ce431c3293ae015038b338bee9491cd94

Contents?: true

Size: 925 Bytes

Versions: 11

Compression:

Stored size: 925 Bytes

Contents

module Rostra
  module Base
    class AnswersController < Rostra::ApplicationController
      load_and_authorize_resource
      before_filter :fetch_question

      def vote
        rostra_user.vote_on(@answer, params[:vote_direction])

        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)
        else
          render :new
        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
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rostra-0.1.15 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.14 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.13 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.12 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.10 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.9 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.8 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.7 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.6 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.5 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.4 app/controllers/rostra/base/answers_controller.rb