Sha256: 32a82a32f5bd4d6496784b2731ba350e849e3d84bbff53ad8271bf8bc5ef679d

Contents?: true

Size: 998 Bytes

Versions: 1

Compression:

Stored size: 998 Bytes

Contents

module Rostra
  class QuestionsController < ApplicationController
    load_and_authorize_resource

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

      respond_to do |format|
        format.html { redirect_to @question }
        format.js
      end
    end

    def index
      @questions = Question.order('created_at desc')
      @user = rostra_user
    end

    def show
      @answers = @question.answers
      impressionist(@question) # increments page views
    end

    def new
    end

    def edit
    end

    def create
      if @question.save
        redirect_to questions_path, notice: 'Your question has been posted.'
      else
        render :new
      end
    end

    def update
      if @question.update_attributes(params[:question])
        redirect_to @question, notice: 'Question was successfully updated.'
      else
        render :edit
      end
    end

    def destroy
      @question.destroy
      redirect_to questions_url
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rostra-0.0.4 app/controllers/rostra/questions_controller.rb