Class: GearsController

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

Overview

This is the controller for Gear.

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_for_mobile, #mobile_device?

Instance Method Details

#createObject

POST /gears POST /gears.json


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/gears_controller.rb', line 29

def create
  @gear = Gear.new(gear_params)
  authorize @gear
  respond_to do |format|
    if @gear.save
      format.html { redirect_to @gear, notice: 'Gear was successfully created.' }
      format.json { render :show, status: :created, location: @gear }
    else
      format.html { render :new }
      format.json { render json: @gear.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /gears/1 DELETE /gears/1.json


59
60
61
62
63
64
65
# File 'app/controllers/gears_controller.rb', line 59

def destroy
  @gear.destroy
  respond_to do |format|
    format.html { redirect_to gears_url, notice: 'Gear was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject

GET /gears/1/edit


25
# File 'app/controllers/gears_controller.rb', line 25

def edit; end

#indexObject

GET /gears GET /gears.json


9
10
11
12
# File 'app/controllers/gears_controller.rb', line 9

def index
  @hunter = Hunter.find(params[:hunter_id]) if params[:hunter_id]
  @gears = Gear.all
end

#newObject

GET /gears/new


19
20
21
22
# File 'app/controllers/gears_controller.rb', line 19

def new
  @gear = Gear.new
  authorize @gear
end

#showObject

GET /gears/1 GET /gears/1.json


16
# File 'app/controllers/gears_controller.rb', line 16

def show; end

#updateObject

PATCH/PUT /gears/1 PATCH/PUT /gears/1.json


45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/gears_controller.rb', line 45

def update
  respond_to do |format|
    if @gear.update(gear_params)
      format.html { redirect_to @gear, notice: 'Gear was successfully updated.' }
      format.json { render :show, status: :ok, location: @gear }
    else
      format.html { render :edit }
      format.json { render json: @gear.errors, status: :unprocessable_entity }
    end
  end
end