/
prefectures_controller.rb
84 lines (72 loc) · 2.15 KB
/
prefectures_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
class PrefecturesController < ApplicationController
before_filter :authenticate_user!, :except => [:index, :show]
# GET /prefectures
# GET /prefectures.xml
def index
@prefectures = Prefecture.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @prefectures }
end
end
# GET /prefectures/1
# GET /prefectures/1.xml
def show
@prefecture = Prefecture.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @prefecture }
end
end
# GET /prefectures/new
# GET /prefectures/new.xml
def new
@prefecture = Prefecture.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @prefecture }
end
end
# GET /prefectures/1/edit
def edit
@prefecture = Prefecture.find(params[:id])
end
# POST /prefectures
# POST /prefectures.xml
def create
@prefecture = Prefecture.new(params[:prefecture])
respond_to do |format|
if @prefecture.save
format.html { redirect_to(@prefecture, :notice => 'Prefecture was successfully created.') }
format.xml { render :xml => @prefecture, :status => :created, :location => @prefecture }
else
format.html { render :action => "new" }
format.xml { render :xml => @prefecture.errors, :status => :unprocessable_entity }
end
end
end
# PUT /prefectures/1
# PUT /prefectures/1.xml
def update
@prefecture = Prefecture.find(params[:id])
respond_to do |format|
if @prefecture.update_attributes(params[:prefecture])
format.html { redirect_to(@prefecture, :notice => 'Prefecture was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @prefecture.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /prefectures/1
# DELETE /prefectures/1.xml
def destroy
@prefecture = Prefecture.find(params[:id])
@prefecture.destroy
respond_to do |format|
format.html { redirect_to(prefectures_url) }
format.xml { head :ok }
end
end
end