質問編集履歴
1
文法の修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -42,4 +42,53 @@
|
|
|
42
42
|
PUT /teams/:id(.:format) teams#update
|
|
43
43
|
DELETE /teams/:id(.:format) teams#destroy
|
|
44
44
|
root GET / team#index
|
|
45
|
+
```
|
|
46
|
+
追記 teams_controller.tb
|
|
47
|
+
```ここに言語を入力
|
|
48
|
+
class TeamsController < ApplicationController
|
|
49
|
+
def index
|
|
50
|
+
@teams = Team.all
|
|
51
|
+
end
|
|
52
|
+
def show
|
|
53
|
+
@team = Team.find params[:id]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def new
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def edit
|
|
60
|
+
@team = Team.find params[:id]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def create
|
|
64
|
+
@team = Team.new(team_params)
|
|
65
|
+
|
|
66
|
+
if @team.save
|
|
67
|
+
redirect_to team_path(@team)
|
|
68
|
+
else
|
|
69
|
+
render 'new'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def update
|
|
74
|
+
@team = Team.find params[:id]
|
|
75
|
+
if @team.update(team_params)
|
|
76
|
+
redirect_to @team
|
|
77
|
+
else
|
|
78
|
+
render 'edit'
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def destroy
|
|
83
|
+
@team = Team.find params[:id]
|
|
84
|
+
@team.destroy
|
|
85
|
+
redirect_to teams_path
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def team_params
|
|
89
|
+
params.require(:team).permit(:name, :text)
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
45
94
|
```
|