問題集のapiをつくろうとしています。
いま、一つの問題の選択肢全部を表示させようとしていますが
ActiveRecord::RecordNotFound (Couldn't find Problem with 'id'=):
というエラーが出ます。
このエラーの意味と直し方を教えてほしいです。いかにselection_contoroller.rbを載せます
lang
1module Api 2 module V1 3 class SelectionsController < ApplicationController 4before_action :set_problem 5 6def index 7@selections=@problem.selections 8render json: @selections, status:200 9end 10 11def show 12@arrey=@problem.selections.to_a 13@selection=@arrey[@problem.answer-1] 14render json: @selection, status:200 15end 16 17private 18def set_problem 19@problem=Problem.find(params[:id]) 20end 21 22 def selection_params 23params.require(:selection).permit(:problem_id, :content) 24end 25 26 end 27 end 28end 29
routingは以下のようになっています
api_v1_problem_selections GET /api/v1/problems/:problem_id/selections(.:format) api/v1/selections#index
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。