2
Rails 5(APIのみ)と非常にシンプルなアプリだと思っていますが、RABLを使ってjsonオブジェクトを返す必要がある間に何らかの理由で空の応答を返しています)Rails api-only rabl filesを無視する
class ExercisesController < ApplicationController
before_action :set_exercise, only: [:show, :update, :destroy]
def index
@exercises = Exercise.all
# Works
# render json: @exercises
# Blank response
render :index
end
end
# app/views/exercises/index.json.rabl
collection @exercises
attributes :id, :name
ダイレクトレンダリング(コメント付き)を使用すると適切に動作しますが、rablテンプレートでは空白になります...任意の考えですか?
実際、 'render'の後に**タイプされたものは**空白を返します(ただしステータスは完全に処理されます)。 'レンダリング'/index'''、 'render'index''を試してみました。 –
'.json'の有無にかかわらず' rabl'ファイルの名前を変更しようとしました。 –
そのアクションに登録されている他のビューはありますか? 'index.html.erb'? 'render text:@excercies.inspect'の出力は何ですか? –