Class: Admin::RobotsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/admin/robots_controller.rb', line 35

def create
  @robot = Robot.new(params[:robot])

  respond_to do |format|
    if @robot.save
      flash[:notice] = 'Robot was successfully created.'
      format.html { redirect_to admin_robot_path(@robot) }
      format.xml  { render xml: @robot, status: :created, location: @robot }
    else
      format.html { render action: 'new' }
      format.xml  { render xml: @robot.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject


63
64
65
66
67
68
69
70
71
# File 'app/controllers/admin/robots_controller.rb', line 63

def destroy
  @robot.destroy
  flash[:notice] = 'Robot removed successfully'

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

#editObject


32
33
# File 'app/controllers/admin/robots_controller.rb', line 32

def edit
end

#find_robot_by_idObject


73
74
75
# File 'app/controllers/admin/robots_controller.rb', line 73

def find_robot_by_id
  @robot = Robot.find(params[:id])
end

#indexObject


7
8
9
10
11
12
13
14
# File 'app/controllers/admin/robots_controller.rb', line 7

def index
  @robots = Robot.all

  respond_to do |format|
    format.html
    format.xml { render xml: @robots }
  end
end

#newObject


23
24
25
26
27
28
29
30
# File 'app/controllers/admin/robots_controller.rb', line 23

def new
  @robot = Robot.new

  respond_to do |format|
    format.html
    format.xml { render xml: @robot }
  end
end

#showObject


16
17
18
19
20
21
# File 'app/controllers/admin/robots_controller.rb', line 16

def show
  respond_to do |format|
    format.html
    format.xml { render xml: @robot }
  end
end

#updateObject


50
51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/admin/robots_controller.rb', line 50

def update
  respond_to do |format|
    if @robot.update(params[:robot])
      flash[:notice] = 'Robot was successfully updated.'
      format.html { redirect_to admin_robot_path(@robot) }
      format.xml  { head :ok }
    else
      format.html { render action: 'edit' }
      format.xml  { render xml: @robot.errors, status: :unprocessable_entity }
    end
  end
end