我认为我有一个非常简单的应用程序,使用 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']
添加到您的配置中。
关于ruby-on-rails - Rails api-only 忽略 rabl 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39358632/