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].present? @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