2016-09-06 7 views
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テンプレートでは空白になります...任意の考えですか?

+0

実際、 'render'の後に**タイプされたものは**空白を返します(ただしステータスは完全に処理されます)。 'レンダリング'/index'''、 'render'index''を試してみました。 –

+0

'.json'の有無にかかわらず' rabl'ファイルの名前を変更しようとしました。 –

+0

そのアクションに登録されている他のビューはありますか? 'index.html.erb'? 'render text:@excercies.inspect'の出力は何ですか? –

答えて

0

設定にconfig.view_paths = ['/app/views']を追加してみてください。

関連する問題