Sha256: d7b5a5a3872f3f4b7b7989e3cd4a5e56d699fc8465b9202be1c27c729f607ed2

Contents?: true

Size: 972 Bytes

Versions: 2

Compression:

Stored size: 972 Bytes

Contents

class SurveyAdmin::QuestionnairesController < SurveyAdmin::BaseController
  def index
    @questionnaires = Questionnaire.all
  end

  def show
    @questionnaire = Questionnaire.includes(:questions).find(params[:id])
  end

  def new
    @questionnaire = Questionnaire.new
    form_info
  end

  def create
    @questionnaire = Questionnaire.new(params[:questionnaire])
    if @questionnaire.save
      redirect_to [:survey_admin, @questionnaire], :notice => "Successfully created questionnaire."
    else
      form_info
      render :new
    end
  end

  def edit
    @questionnaire = Questionnaire.find(params[:id])
    form_info
  end

  def update
    @questionnaire = Questionnaire.find(params[:id])
    if @questionnaire.update_attributes(params[:questionnaire])
      redirect_to [:survey_admin, @questionnaire], :notice  => "Successfully updated questionnaire."
    else
      form_info
      render :edit
    end
  end

  private
    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/questionnaires_controller.rb
survey_says-0.0.1 app/controllers/survey_admin/questionnaires_controller.rb