Sha256: 96cb2dd26e759cd7b7a80dbd195f40f2c56d658ba3d0a33855e8d0ec99152455

Contents?: true

Size: 924 Bytes

Versions: 19

Compression:

Stored size: 924 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

19 entries across 19 versions & 1 rubygems

Version Path
rostra-0.3.6 app/controllers/rostra/base/answers_controller.rb
rostra-0.3.5 app/controllers/rostra/base/answers_controller.rb
rostra-0.3.4 app/controllers/rostra/base/answers_controller.rb
rostra-0.3.3 app/controllers/rostra/base/answers_controller.rb
rostra-0.3.2 app/controllers/rostra/base/answers_controller.rb
rostra-0.3.1 app/controllers/rostra/base/answers_controller.rb
rostra-0.2.1 app/controllers/rostra/base/answers_controller.rb
rostra-0.2.0 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.26 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.25 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.24 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.23 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.22 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.21 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.20 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.19 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.18 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.17 app/controllers/rostra/base/answers_controller.rb
rostra-0.1.16 app/controllers/rostra/base/answers_controller.rb