Skip to content

Instantly share code, notes, and snippets.

@hardbap
Forked from brookr/gist:76566
Created March 9, 2009 23:59
Show Gist options
  • Save hardbap/76568 to your computer and use it in GitHub Desktop.
Save hardbap/76568 to your computer and use it in GitHub Desktop.
class SurveysController < ApplicationController
# GET /surveys
# GET /surveys.xml
def index
@surveys = Survey.find(:all, :limit => 50)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @surveys }
end
end
# GET /surveys/1
# GET /surveys/1.xml
def show
@survey = Survey.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @survey }
end
end
# GET /surveys/new
# GET /surveys/new.xml
def new
@survey = Survey.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @survey }
end
end
# GET /surveys/1/edit
def edit
@survey = Survey.find(params[:id])
end
# POST /surveys
# POST /surveys.xml
def create
@survey = Survey.new(params[:survey])
respond_to do |format|
if @survey.save
flash[:notice] = 'Survey was successfully created.'
format.html { redirect_to(@survey) }
format.xml { render :xml => @survey, :status => :created, :location => @survey }
else
format.html { render :action => "new" }
format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }
end
end
end
# PUT /surveys/1
# PUT /surveys/1.xml
def update
@survey = Survey.find(params[:id])
respond_to do |format|
if @survey.update_attributes(params[:survey])
flash[:notice] = 'Survey was successfully updated.'
format.html { redirect_to(@survey) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /surveys/1
# DELETE /surveys/1.xml
def destroy
@survey = Survey.find(params[:id])
@survey.destroy
flash[:notice] = 'Survey was successfully deleted.'
respond_to do |format|
format.html { redirect_to(surveys_url) }
format.xml { head :ok }
end
end
# GET /surveys/check/1
def check
@survey = Survey.find(params[:id])
@staff = @survey.staff
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment