0

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

4

1 回答 1

0

有一个before_update作为资源回调存在的钩子。根据文档,这是最新稳定指南中的建议选项

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.

如果你想覆盖整个动作,我相信你需要编写自己的自定义处理器。我认为对于更新,您需要查看替换字段。我将从更新操作开始并沿着process_request链条进行。

于 2019-01-16T16:15:49.753 回答