スキャフォールディングは、Create/Update メソッドを持つコントローラーを作成します。これらのメソッドには、HTML と JSON のレンダリングがあります。HTML は知っていますが、JSON が何であるかはわかりません。そこに JSON を含める必要がありますか?それとも、それを取り出しても HTML レンダリングで作業できますか?
話しているコードは次のとおりです。
def create
@judge = Judge.new(judge_params)
respond_to do |format|
if @judge.save
format.html { redirect_to @judge, notice: 'Judge was successfully created.' }
format.json { render action: 'show', status: :created, location: @judge }
else
format.html { render action: 'new' }
format.json { render json: @judge.errors, status: :unprocessable_entity }
end
end
end