Class: Trade::Admin::ProducesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/trade/admin/produces_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/trade/admin/produces_controller.rb', line 18

def create
  @produce = Produce.new(produce_params)

  respond_to do |format|
    if @produce.save
      format.html { redirect_to @produce }
      format.json { render :show, status: :created, location: @produce }
    else
      format.html { render :new }
      format.json { render json: @produce.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /produces/1 DELETE /produces/1.json



48
49
50
51
52
53
54
# File 'app/controllers/trade/admin/produces_controller.rb', line 48

def destroy
  @produce.destroy
  respond_to do |format|
    format.html { redirect_to produces_url }
    format.json { head :no_content }
  end
end

#editObject



15
16
# File 'app/controllers/trade/admin/produces_controller.rb', line 15

def edit
end

#indexObject



4
5
6
# File 'app/controllers/trade/admin/produces_controller.rb', line 4

def index
  @produces = Produce.all
end

#newObject



11
12
13
# File 'app/controllers/trade/admin/produces_controller.rb', line 11

def new
  @produce = Produce.new
end

#showObject



8
9
# File 'app/controllers/trade/admin/produces_controller.rb', line 8

def show
end

#updateObject

PATCH/PUT /produces/1 PATCH/PUT /produces/1.json



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/trade/admin/produces_controller.rb', line 34

def update
  respond_to do |format|
    if @produce.update(produce_params)
      format.html { redirect_to @produce }
      format.json { render :show, status: :ok, location: @produce }
    else
      format.html { render :edit }
      format.json { render json: @produce.errors, status: :unprocessable_entity }
    end
  end
end