# -*- encoding : utf-8 -*-

class SurveySetsController < ApplicationController
  
  http_basic_authenticate_with :name => "stats", :password => "stats", :only => [:edit, :show]
  
  def index
   
  end
  def new 
    
    @survey = SurveyType.find_by_slug(params[:slug])
    @survey_set = @survey.to_survey_set
  end
  
  def edit 
    @survey_set = SurveySet.find(params[:id])
  end
  
  def create
    @survey_set = SurveySet.new(params[:survey_set])
    if @survey_set.save
      redirect_to thank_survey_set_path(:slug => @survey_set.survey_type.slug)
    else
      render :action => :new
    end
  end
  
  def show
    @survey = SurveyType.find_by_slug(params[:slug])
  end
  
  def thank
     @survey = SurveyType.find_by_slug(params[:slug])
  end
end
