Sha256: da0ff125004674484ad66ef2bbce4090fb83a69adc3fab2f1b90089dc2823f24
Contents?: true
Size: 1.76 KB
Versions: 5
Compression:
Stored size: 1.76 KB
Contents
module Rostra module Base 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 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
5 entries across 5 versions & 1 rubygems