-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathtypes_controller.rb
92 lines (79 loc) · 2.02 KB
/
types_controller.rb
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
class TypesController < ApplicationController
# GET /types
# GET /types.json
def index
@types = Type.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @types }
end
end
# GET /types/1
# GET /types/1.json
def show
@type = Type.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @type }
end
end
# GET /types/new
# GET /types/new.json
def new
@type = Type.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @type }
end
end
# GET /types/1/edit
def edit
@type = Type.find(params[:id])
end
# POST /types
# POST /types.json
def create
@type = Type.new(params[:type])
respond_to do |format|
if @type.save
format.html { redirect_to @type, notice: 'Type was successfully created.' }
format.json { render json: @type, status: :created, location: @type }
else
format.html { render action: "new" }
format.json { render json: @type.errors, status: :unprocessable_entity }
end
end
end
# PUT /types/1
# PUT /types/1.json
def update
@type = Type.find(params[:id])
respond_to do |format|
if @type.update_attributes(params[:type])
format.html { redirect_to @type, notice: 'Type was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @type.errors, status: :unprocessable_entity }
end
end
end
# DELETE /types/1
# DELETE /types/1.json
def destroy
@type = Type.find(params[:id])
@type.destroy
respond_to do |format|
format.html { redirect_to types_url }
format.json { head :no_content }
end
end
# ordered_index
def ordered_index
@types = Type.find(:all, :order => :name)
respond_to do |format|
format.html { render action: "index" }
format.json { render json: @types }
end
end
end