1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
class NutrientProfilesController < ApplicationController
before_action :set_crop, only: %i[ show edit update destroy ]
def index
@crops = Crop.all
end
def show
end
def new
@crop = Crop.new
end
def edit
end
def create
@crop = Crop.new(crop_params)
if @crop.save
redirect_to @crop, notice: "Crop was successfully created."
else
render :new, status: :unprocessable_entity
end
end
def update
respond_to do |format|
if @crop.update(crop_params)
format.html { redirect_to @crop, notice: "Crop was successfully updated.", status: :see_other }
format.json { render :show, status: :ok, location: @crop }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @crop.errors, status: :unprocessable_entity }
end
end
end
def destroy
@crop.destroy!
respond_to do |format|
format.html { redirect_to crops_path, notice: "Crop was successfully destroyed.", status: :see_other }
format.json { head :no_content }
end
end
private
def set_crop
@crop = Crop.find(params.expect(:id))
end
def crop_params
params.expect(crop: [ :name, :crop_type, :nno3, :p, :k, :ca, :mg, :s, :na, :cl, :si, :fe, :zn, :b, :mn, :cu, :mo, :nnh4 ])
end
end
|