Class: CommandsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/commands_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /commands POST /commands.xml



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/commands_controller.rb', line 46

def create
  @command = Command.new(command_params)

  respond_to do |format|
    _result = @command.save
    @commands_nb = Command.count
    @commands = Command.all

    if _result
#        @command_result = %x[#{@command.execute.to_s}]
      execute_command

      @command = Command.new
      format.html { render :action => "new" }
      format.xml  { render :xml => @command, :status => :created, :location => @command }
    else
      format.html { redirect_to(@command) }
      format.xml  { render :xml => @command.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /commands/1 DELETE /commands/1.xml



93
94
95
96
97
98
99
100
101
# File 'app/controllers/commands_controller.rb', line 93

def destroy
  @command = Command.find(params[:id])
  @command.destroy

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

#executeObject

GET /commands/1/execute GET /commands/1/execute.xml



70
71
72
73
74
75
76
77
78
# File 'app/controllers/commands_controller.rb', line 70

def execute
  @command = Command.find(params[:id])
  execute_command

  respond_to do |format|
    format.html { render :action => "executed" }
    format.xml  { render :xml => @command }
  end
end

#executedObject

GET /commands/1/executed GET /commands/1/executed.xml



82
83
84
85
86
87
88
89
# File 'app/controllers/commands_controller.rb', line 82

def executed
  @command = Command.find(params[:id])

  respond_to do |format|
    format.html { render :action => "execute" }
    format.xml  { render :xml => @command }
  end
end

#indexObject

GET /commands GET /commands.xml



12
13
14
15
16
17
18
19
20
# File 'app/controllers/commands_controller.rb', line 12

def index
  @commands_nb = Command.count
  @commands = Command.all

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

#newObject

GET /commands/new GET /commands/new.xml



35
36
37
38
39
40
41
42
# File 'app/controllers/commands_controller.rb', line 35

def new
  @command = Command.new

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

#showObject

GET /commands/1 GET /commands/1.xml



24
25
26
27
28
29
30
31
# File 'app/controllers/commands_controller.rb', line 24

def show
  @command = Command.find(params[:id])

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