Class: SectionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/sections_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /sections POST /sections.xml



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/sections_controller.rb', line 43

def create
  @section = SurveySection.new(params[:section])

  respond_to do |format|
    if @section.save
      flash[:notice] = 'Section was successfully created.'
      format.html { redirect_to(@section) }
      format.xml  { render :xml => @section, :status => :created, :location => @section }
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @section.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /sections/1 DELETE /sections/1.xml



77
78
79
80
81
82
83
84
85
# File 'app/controllers/sections_controller.rb', line 77

def destroy
  @section = SurveySection.find(params[:id])
  @section.destroy

  respond_to do |format|
    format.html { redirect_to(sections_url) }
    format.xml  { head :ok }
  end
end

#editObject

GET /sections/1/edit



37
38
39
# File 'app/controllers/sections_controller.rb', line 37

def edit
  @section = SurveySection.find(params[:id])
end

#indexObject

GET /sections.xml



5
6
7
8
9
10
11
12
# File 'app/controllers/sections_controller.rb', line 5

def index
  @sections = SurveySection.find(:all)

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @sections }
  end
end

#newObject

GET /sections/new GET /sections/new.xml



27
28
29
30
31
32
33
34
# File 'app/controllers/sections_controller.rb', line 27

def new
  @section = SurveySection.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @section }
  end
end

#showObject

GET /sections/1 GET /sections/1.xml



16
17
18
19
20
21
22
23
# File 'app/controllers/sections_controller.rb', line 16

def show
  @section = SurveySection.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml  { render :xml => @section.to_xml(:include => :questions) }
  end
end

#updateObject

PUT /sections/1 PUT /sections/1.xml



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/sections_controller.rb', line 60

def update
  @section = SurveySection.find(params[:id])

  respond_to do |format|
    if @section.update_attributes(params[:section])
      flash[:notice] = 'Section was successfully updated.'
      format.html { redirect_to(@section) }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @section.errors, :status => :unprocessable_entity }
    end
  end
end