Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,有多个控制器/动作可以修改同一个模型。我需要记录进行了更新,还需要记录哪个动作/控制器发起了请求。是否可以在 after_update 中而不是在每个进行更新的操作中这样做? 我正在使用 Rails 2.3.8
不,after_update属于模型级别,它无权访问控制器。
after_update
至少您可以使用after_update在日志中写入:当您想查看它发生在哪个控制器上时,您可以浏览日志以在上面的行中找到控制器。