Rails API 版本控制狂欢 + rabl

Rails API Versioning Spree + rabl

我有一个使用 Spree 构建的电子商务应用程序,现在我需要为某个控制器创建 API 的新版本,这就是我所做的

当我尝试访问 api 我的请求触发了操作,但我不断收到错误消息

ActionView::MissingTemplate (Missing template spree/api/v2/x/index)

我应该做哪些缺少的配置?!

您的 RABL 视图应该在

app/views/api/v2/x/index.rabl

There is a naming convention for views in Rails. Typically, the views share their name with the associated controller action. For example, the index controller action of the articles_controller.rb will use the index.html.erb view file in the app/views/articles directory. The complete HTML returned to the client is composed of a combination of this ERB file, a layout template that wraps it, and all the partials that the view may reference.