Sha256: cb1663b3c75cdae15454d6243c936b3431fbb833f6b81de6fde4da9848499560

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

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
      if params[:tag_search]
        @questions = Question.tagged_with(params[:tag_search]).order('created_at desc')
      else
        @questions = Question.order('created_at desc')
      end
    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

8 entries across 8 versions & 1 rubygems

Version Path
rostra-0.0.12 app/controllers/rostra/questions_controller.rb
rostra-0.0.11 app/controllers/rostra/questions_controller.rb
rostra-0.0.10 app/controllers/rostra/questions_controller.rb
rostra-0.0.9 app/controllers/rostra/questions_controller.rb
rostra-0.0.8 app/controllers/rostra/questions_controller.rb
rostra-0.0.7 app/controllers/rostra/questions_controller.rb
rostra-0.0.6 app/controllers/rostra/questions_controller.rb
rostra-0.0.5 app/controllers/rostra/questions_controller.rb