Class: Admin::RobotsController

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

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#createObject

rubocop:todo Metrics/AbcSize


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

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


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

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
# File 'app/controllers/admin/robots_controller.rb', line 34

def edit; end

#find_robot_by_idObject


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

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


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

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