Sha256: c7fc9fc128cb4b735588153599e40857eacf8e5b6b8dc0d239c3c3bbf5902f55
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
module Rapidfire class QuestionsController < Rapidfire::ApplicationController before_filter :authenticate_administrator! respond_to :html, :js before_filter :find_question_group! before_filter :find_question!, :only => [:edit, :update, :destroy] def index @questions = @question_group.questions respond_with(@questions) end def new @question = QuestionForm.new(:question_group => @question_group) respond_with(@question) end def create form_params = params[:question].merge(:question_group => @question_group) @question = QuestionForm.new(form_params) @question.save respond_with(@question, location: index_location) end def edit @question = QuestionForm.new(:question => @question) respond_with(@question) end def update form_params = params[:question].merge(:question => @question) @question = QuestionForm.new(form_params) @question.save respond_with(@question, location: index_location) end def destroy @question.destroy respond_with(@question, location: index_location) end private def find_question_group! @question_group = QuestionGroup.find(params[:question_group_id]) end def find_question! @question = @question_group.questions.find(params[:id]) end def index_location rapidfire.question_group_questions_url(@question_group) end end end
Version data entries
3 entries across 3 versions & 2 rubygems