Rails api-only忽略rabl文件
我有一个非常简单的应用程序,使用Rails 5(仅限API),但由于某种原因它返回一个空响应,而它应该返回一个json对象(使用RABL)
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模板它是空白的…任何想法?
尝试将config.view_paths = ['/app/views']
到您的配置中。