【问题标题】:How to override a PATCH request using JSONAPI::Resources如何使用 JSONAPI::Resources 覆盖 PATCH 请求
【发布时间】:2019-01-16 10:57:30
【问题描述】:

如何拦截update 操作并在resource.rb 文件中覆盖它,而不是在控制器中。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 jsonapi-resources


    【解决方案1】:

    有一个before_update 钩子以resource callback 的形式存在。根据文档,这是最新 stable guide

    中的建议选项
    Note: The authors of this gem expect the most common uses cases to be
    handled using the callbacks. It is likely that the internal functionality 
    of the operation processing methods will change, at least for several
    revisions. Effort will be made to call this out in release notes. You 
    have been warned.
    

    如果你想覆盖整个动作,我相信你需要编写自己的自定义处理器。我认为您需要查看replace fields 的更新。我会从update 操作开始,然后沿着process_request 循序渐进。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-25
      • 2016-01-24
      相关资源
      最近更新 更多