Class: OutcomesController

Inherits:
ApplicationController show all
Defined in:
lib/branston/app/controllers/outcomes_controller.rb

Overview

This file is part of Branston.

Branston is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation.

Branston is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Branston.  If not, see <http://www.gnu.org/licenses/>.

Instance Method Summary collapse

Instance Method Details

#createObject

POST /outcomes POST /outcomes.xml



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 65

def create
  @outcome = Outcome.new(params[:outcome])
  @outcome.scenario = @scenario
  @outcomes = @scenario.outcomes
  respond_to do |format|
    if @outcome.save
      flash[:notice] = 'Outcome was successfully created.'
      format.html { redirect_to(@outcome) }
      format.xml  { render :xml => @outcome, :status => :created, :location => @outcome }
      format.js
    else
      format.html { render :action => "new" }
      format.xml  { render :xml => @outcome.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /outcomes/1 DELETE /outcomes/1.xml



101
102
103
104
105
106
107
108
109
110
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 101

def destroy
  @outcome = Outcome.find(params[:id])
  @outcome.destroy

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

#editObject

GET /outcomes/1/edit



59
60
61
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 59

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

#indexObject

GET /outcomes GET /outcomes.xml



24
25
26
27
28
29
30
31
32
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 24

def index
  @outcomes = @scenario.outcomes

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

#newObject

GET /outcomes/new GET /outcomes/new.xml



47
48
49
50
51
52
53
54
55
56
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 47

def new
  @outcome = Outcome.new
  @outcomes = @scenario.outcomes
  @outcomes.push @outcome
  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @outcome }
    format.js
  end
end

#showObject

GET /outcomes/1 GET /outcomes/1.xml



36
37
38
39
40
41
42
43
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 36

def show
  @outcome = Outcome.find(params[:id])

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

#updateObject

PUT /outcomes/1 PUT /outcomes/1.xml



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/branston/app/controllers/outcomes_controller.rb', line 84

def update
  @outcome = Outcome.find(params[:id])

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