Class: SummariesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/summaries_controller.rb', line 17

def create
  @summary = summary.new(params[:summary])
  if @summary.save
    flash[:notice] = "Successfully created summary."
    redirect_to @summary
  else
    render :action => 'new'
  end
end

#destroyObject



41
42
43
44
45
46
# File 'app/controllers/summaries_controller.rb', line 41

def destroy
  @summary = summary.find(params[:id])
  @summary.destroy
  flash[:notice] = "Successfully destroyed summary."
  redirect_to summaries_url
end

#editObject



27
28
29
# File 'app/controllers/summaries_controller.rb', line 27

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

#indexObject



2
3
4
# File 'app/controllers/summaries_controller.rb', line 2

def index
  @summaries = Summary.all
end

#newObject



12
13
14
15
# File 'app/controllers/summaries_controller.rb', line 12

def new
  @summary = Summary.new
  @survey = Survey.find(1)
end

#showObject



6
7
8
9
10
# File 'app/controllers/summaries_controller.rb', line 6

def show
  authenticate_user!
  @summary = summary.find(params[:id])
  @summary_answer = summaryAnswer.new
end

#updateObject



31
32
33
34
35
36
37
38
39
# File 'app/controllers/summaries_controller.rb', line 31

def update
  @summary = summary.find(params[:id])
  if @summary.update_attributes(params[:summary])
    flash[:notice] = "Successfully updated summary."
    redirect_to @summary
  else
    render :action => 'edit'
  end
end