Class: CommandsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CommandsController
- Defined in:
- app/controllers/commands_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /commands POST /commands.xml.
-
#destroy ⇒ Object
DELETE /commands/1 DELETE /commands/1.xml.
-
#execute ⇒ Object
GET /commands/1/execute GET /commands/1/execute.xml.
-
#executed ⇒ Object
GET /commands/1/executed GET /commands/1/executed.xml.
-
#index ⇒ Object
GET /commands GET /commands.xml.
-
#new ⇒ Object
GET /commands/new GET /commands/new.xml.
-
#show ⇒ Object
GET /commands/1 GET /commands/1.xml.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#execute ⇒ Object
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 |
#executed ⇒ Object
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 |
#index ⇒ Object
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 |
#new ⇒ Object
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 |
#show ⇒ Object
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 |