Class: HuntersImprovementsController

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

Overview

Controller for HuntersImprovements

Instance Method Summary collapse

Methods inherited from ApplicationController

#check_for_mobile, #mobile_device?

Instance Method Details

#createObject

POST /hunters_improvements POST /hunters_improvements.json


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/hunters_improvements_controller.rb', line 31

def create
  @hunters_improvement = HuntersImprovement.new(hunters_improvement_params)
  @hunters_improvement.hunter = @hunter
  update_improvable_option
  authorize @hunters_improvement

  respond_to do |format|
    if @hunters_improvement.save
      format.html do
        redirect_to hunter_hunters_improvement_url(hunter_id: @hunter.id, id: @hunters_improvement.id),
                    notice: 'Hunters improvement was successfully created.'
      end
      format.json do
        render :show,
               status: :created,
               location: hunter_hunters_improvement_url(hunter_id: @hunter.id, id: @hunters_improvement.id)
      end
    else
      format.html { render :new }
      format.json { render json: @hunters_improvement.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /hunters_improvements/1 DELETE /hunters_improvements/1.json


79
80
81
82
83
84
85
86
87
# File 'app/controllers/hunters_improvements_controller.rb', line 79

def destroy
  @hunters_improvement.destroy
  respond_to do |format|
    format.html do
      redirect_to hunter_hunters_improvements_url, notice: 'Hunters improvement was successfully destroyed.'
    end
    format.json { head :no_content }
  end
end

#editObject

GET /hunters_improvements/1/edit


27
# File 'app/controllers/hunters_improvements_controller.rb', line 27

def edit; end

#indexObject

GET /hunters_improvements GET /hunters_improvements.json


11
12
13
# File 'app/controllers/hunters_improvements_controller.rb', line 11

def index
  @hunters_improvements = HuntersImprovement.all
end

#newObject

GET /hunters_improvements/new


20
21
22
23
24
# File 'app/controllers/hunters_improvements_controller.rb', line 20

def new
  @hunters_improvement = HuntersImprovement.new(hunter: @hunter)
  @hunters_improvement.improvement = Improvement.find(params[:improvement_id]) if params[:improvement_id]
  authorize @hunters_improvement
end

#showObject

GET /hunters_improvements/1 GET /hunters_improvements/1.json


17
# File 'app/controllers/hunters_improvements_controller.rb', line 17

def show; end

#updateObject

PATCH/PUT /hunters_improvements/1 PATCH/PUT /hunters_improvements/1.json


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/controllers/hunters_improvements_controller.rb', line 57

def update
  respond_to do |format|
    update_improvable_option
    if @hunters_improvement.update(hunters_improvement_params)
      format.html do
        redirect_to hunter_hunters_improvement_url(hunter_id: @hunter.id, id: @hunters_improvement.id),
                    notice: 'Hunters improvement was successfully updated.'
      end
      format.json do
        render :show,
               status: :ok,
               location: hunter_hunters_improvement_url(hunter_id: @hunter.id, id: @hunters_improvement.id)
      end
    else
      format.html { render :edit }
      format.json { render json: @hunters_improvement.errors, status: :unprocessable_entity }
    end
  end
end