質問編集履歴
1
parties_controllerを追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -145,4 +145,69 @@
|
|
145
145
|
|
146
146
|
▼ 仮説と検証作業の結果
|
147
147
|
仮説として問題が、hamlの記述かもしくはモデルにあると思っていますが見当つきません。
|
148
|
-
何か気づきがありましたらご意見頂戴したいです。
|
148
|
+
何か気づきがありましたらご意見頂戴したいです。
|
149
|
+
|
150
|
+
### 追記 [2020.9.12]
|
151
|
+
▼ parties_controller
|
152
|
+
```
|
153
|
+
class PartiesController < ApplicationController
|
154
|
+
|
155
|
+
def index
|
156
|
+
end
|
157
|
+
|
158
|
+
def new
|
159
|
+
@pokemon = Pokemon.new
|
160
|
+
@party = Party.new
|
161
|
+
@party.build_pokemon
|
162
|
+
end
|
163
|
+
|
164
|
+
def create
|
165
|
+
@pokemon = Pokemon.new(pokemon_params)
|
166
|
+
@pokemon.save
|
167
|
+
@party = Party.new(party_params)
|
168
|
+
@party.save
|
169
|
+
redirect_to root_path, notice: 'パーティを作成しました'
|
170
|
+
end
|
171
|
+
|
172
|
+
def show
|
173
|
+
@party = Party.find(params[:id])
|
174
|
+
end
|
175
|
+
|
176
|
+
def edit
|
177
|
+
@party = Party.find(params[:id])
|
178
|
+
end
|
179
|
+
|
180
|
+
def update
|
181
|
+
@party = Party.find(params[:id])
|
182
|
+
end
|
183
|
+
|
184
|
+
def destroy
|
185
|
+
@party = Party.find(params[:id])
|
186
|
+
end
|
187
|
+
|
188
|
+
private
|
189
|
+
|
190
|
+
def pokemon_params
|
191
|
+
params.permit(
|
192
|
+
:name, :nickname, :gender, :ability, :nature, :item, :move1, :move2, :move3, :move4,
|
193
|
+
:cs_hp, :cs_attack, :cs_defense, :cs_special_attack, :cs_special_defense, :cs_speed,
|
194
|
+
:bs_hp, :bs_attack, :bs_defense, :bs_special_attack, :bs_special_defense, :bs_speed,
|
195
|
+
:ev_hp, :ev_attack, :ev_defense, :ev_special_attack, :ev_special_defense, :ev_speed
|
196
|
+
)
|
197
|
+
end
|
198
|
+
|
199
|
+
def party_params
|
200
|
+
params.permit(
|
201
|
+
:party_name,
|
202
|
+
pokemons_attributes:[
|
203
|
+
:name, :nickname, :gender, :ability, :nature, :item, :move1, :move2, :move3, :move4,
|
204
|
+
:cs_hp, :cs_attack, :cs_defense, :cs_special_attack, :cs_special_defense, :cs_speed,
|
205
|
+
:bs_hp, :bs_attack, :bs_defense, :bs_special_attack, :bs_special_defense, :bs_speed,
|
206
|
+
:ev_hp, :ev_attack, :ev_defense, :ev_special_attack, :ev_special_defense, :ev_speed
|
207
|
+
]
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
```
|