Sha256: 7a559cba3c2586b1534191d73490b0b9fa73b45001dc6abb5e238d9c11c4174f
Contents?: true
Size: 1.76 KB
Versions: 11
Compression:
Stored size: 1.76 KB
Contents
module Rostra module Base class QuestionsController < Rostra::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 toggle_following if rostra_user.following?(@question) rostra_user.followed_questions.delete(@question) else rostra_user.question_followings.create(question: @question, send_email_notifications: false) end respond_to do |format| format.html { redirect_to @question } format.js end end def tags tags = Question.tag_counts.where("name like ?", "%#{params[:q]}%").limit(10) respond_to do |format| format.js { render :js => tags.map { |tag| {value: tag.name} }.to_json } end end def index if params[:tag_search].present? @questions = Question.tagged_with(params[:tag_search]).order('created_at desc').page(params[:page]) else @questions = Question.order('created_at desc').page(params[:page]) 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 end end end
Version data entries
11 entries across 11 versions & 1 rubygems