Class: Admin::RobotsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

rubocop:todo Metrics/AbcSize, Metrics/MethodLength



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

def create # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
  @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



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

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



34
35
# File 'app/controllers/admin/robots_controller.rb', line 34

def edit
end

#find_robot_by_idObject



75
76
77
# File 'app/controllers/admin/robots_controller.rb', line 75

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

#indexObject



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

def index
  @robots = Robot.all

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

#newObject



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

def new
  @robot = Robot.new

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

#showObject



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

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

#updateObject



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

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