Class: ScenariosController

Inherits:
ApplicationController show all
Defined in:
lib/branston/app/controllers/scenarios_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 /stories/:story_id/scenarios POST /stories/:story_id/scenarios.xml



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

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

#destroyObject

DELETE /stories/1 DELETE /stories/1.xml



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 98

def destroy
  @scenario = Scenario.find(params[:id])
  @story = @scenario.story
  @scenario.destroy

  respond_to do |format|
    format.html { redirect_to(iteration_story_scenarios_path(@iteration, @story)) }
    format.xml  { head :ok }
    format.js
  end
end

#editObject

GET /scenarios/1/edit



57
58
59
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 57

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

#indexObject



23
24
25
26
27
28
29
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 23

def index
  @scenarios = @story.scenarios
  respond_to do |format|
    format.html
    format.js
  end
end

#newObject

GET /stories/:story_id/scenarios/new GET /stories/:story_id/scenarios/new.xml



44
45
46
47
48
49
50
51
52
53
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 44

def new
  @scenario = Scenario.new
  @scenarios = @story.scenarios
  @scenarios.push @scenario
  respond_to do |format|
    format.html # new.html.erb
    format.xml  { render :xml => @story }
    format.js
  end
end

#showObject

GET /scenarios/1 GET /scenarios/1.xml



33
34
35
36
37
38
39
40
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 33

def show
  @scenario = Scenario.find(params[:id])

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

#updateObject

PUT /scenarios/1 PUT /scenarios/1.xml



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/branston/app/controllers/scenarios_controller.rb', line 82

def update
  @scenario = Scenario.find(params[:id])
  respond_to do |format|
    if @scenario.update_attributes(params[:scenario])
      flash[:notice] = 'Scenario was successfully updated.'
      format.html { redirect_to iteration_story_scenario_path(@iteration, @story, @scenario) }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @scenario.errors, :status => :unprocessable_entity }
    end
  end
end