質問編集履歴
3
解決
test
CHANGED
File without changes
|
test
CHANGED
@@ -375,3 +375,33 @@
|
|
375
375
|
ActiveRecord::RecordNotFound (Couldn't find Category without an ID):
|
376
376
|
|
377
377
|
```
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
#解決
|
382
|
+
|
383
|
+
id(#)の指定忘れ
|
384
|
+
|
385
|
+
JSファイルでイベントがあったところのvalを取ってくる記述でidを指定するはずが、$("parent_category_forecast")でなっておりidでもクラスでもなかった
|
386
|
+
|
387
|
+
皆様ありがとうございました
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
```
|
392
|
+
|
393
|
+
$("#parent_category_forecast").on("change",function(){
|
394
|
+
|
395
|
+
let parentCategory = $("parent_category_forecast").val();
|
396
|
+
|
397
|
+
```
|
398
|
+
|
399
|
+
修正
|
400
|
+
|
401
|
+
```
|
402
|
+
|
403
|
+
$("#parent_category_forecast").on("change",function(){
|
404
|
+
|
405
|
+
let parentCategory = $("#parent_category_forecast").val();
|
406
|
+
|
407
|
+
```
|
2
うう
test
CHANGED
File without changes
|
test
CHANGED
@@ -363,3 +363,15 @@
|
|
363
363
|
end
|
364
364
|
|
365
365
|
```
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
ターミナルのエラー
|
370
|
+
|
371
|
+
カテゴリにidが見つからない コントローラーに問題?
|
372
|
+
|
373
|
+
```
|
374
|
+
|
375
|
+
ActiveRecord::RecordNotFound (Couldn't find Category without an ID):
|
376
|
+
|
377
|
+
```
|
1
h
test
CHANGED
File without changes
|
test
CHANGED
@@ -261,3 +261,105 @@
|
|
261
261
|
end
|
262
262
|
|
263
263
|
```
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
###追記
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
ルーティング
|
272
|
+
|
273
|
+
```
|
274
|
+
|
275
|
+
Rails.application.routes.draw do
|
276
|
+
|
277
|
+
root 'tops#index'
|
278
|
+
|
279
|
+
devise_for :users
|
280
|
+
|
281
|
+
resources :tweets do
|
282
|
+
|
283
|
+
resources :comments,only:[:create,:destroy]
|
284
|
+
|
285
|
+
resources :likes,only:[:create,:destroy]
|
286
|
+
|
287
|
+
collection do
|
288
|
+
|
289
|
+
get :search
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
294
|
+
|
295
|
+
resources :tournaments,only:[:show] do
|
296
|
+
|
297
|
+
member do
|
298
|
+
|
299
|
+
get "watch"
|
300
|
+
|
301
|
+
get "watch_avg"
|
302
|
+
|
303
|
+
end
|
304
|
+
|
305
|
+
end
|
306
|
+
|
307
|
+
resources :analyses,only:[:index,:new,:create,:destroy,:edit,:update]
|
308
|
+
|
309
|
+
resources :forecasts,only:[:index,:new,:create]
|
310
|
+
|
311
|
+
resources :tops,only:[:index]
|
312
|
+
|
313
|
+
end
|
314
|
+
|
315
|
+
```
|
316
|
+
|
317
|
+
コントローラー
|
318
|
+
|
319
|
+
```
|
320
|
+
|
321
|
+
class ForecastsController < ApplicationController
|
322
|
+
|
323
|
+
before_action :set_category, only: [:new]
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
def index
|
328
|
+
|
329
|
+
@tweets = Forecast.includes(:user).page(params[:page]).per(5).order("created_at DESC")
|
330
|
+
|
331
|
+
end
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
def new
|
336
|
+
|
337
|
+
@forecast = Forecast.new
|
338
|
+
|
339
|
+
respond_to do |format|
|
340
|
+
|
341
|
+
format.html
|
342
|
+
|
343
|
+
format.json do
|
344
|
+
|
345
|
+
@category_children = Category.find(params[:tournament_id]).children
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
end
|
350
|
+
|
351
|
+
end
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
private
|
356
|
+
|
357
|
+
def set_category
|
358
|
+
|
359
|
+
@category_parent_array = Category.where(ancestry: nil)
|
360
|
+
|
361
|
+
end
|
362
|
+
|
363
|
+
end
|
364
|
+
|
365
|
+
```
|