Sha256: f7d2403e7793353e2632dbb5c93b89b289605954134596121f1e2fe35c103f26
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
class SurveyAdmin::QuestionsController < SurveyAdmin::BaseController helper_method :questionnaire_options def index @questions = Question.all end def show @question = Question.includes(:answers).find(params[:id]) end def new form_info @question = Question.new #@question.answers.build# = Question.new end def create @question = Question.new(params[:question]) if @question.save flash[:notice] = "Successfully created question." redirect_to survey_admin_question_answers_url(@question) else form_info render :action => 'new' end end def edit form_info @question = Question.find(params[:id]) end def update @question = Question.find(params[:id]) if @question.update_attributes(params[:question]) flash[:notice] = "Successfully updated question." redirect_to survey_admin_question_answers_url(@question) else form_info render :action => 'edit' end end def destroy @question = Question.find(params[:id]) @question.active = false @question.save flash[:notice] = "Successfully inactivated." redirect_to survey_admin_questions_url end private def questionnaire_options @questionnaire_options ||= Questionnaire.all.map{|q| [q.name, q.id]} end def form_info end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
survey_says-0.0.2 | app/controllers/survey_admin/questions_controller.rb |
survey_says-0.0.1 | app/controllers/survey_admin/questions_controller.rb |