【发布时间】:2019-01-16 10:57:30
【问题描述】:
如何拦截update 操作并在resource.rb 文件中覆盖它,而不是在控制器中。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 jsonapi-resources
如何拦截update 操作并在resource.rb 文件中覆盖它,而不是在控制器中。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 jsonapi-resources
有一个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 循序渐进。
【讨论】: