我看过ActiveSupport::Notifications的文档,但我不太清楚如何使用它。这就是我现在所拥有的:
class Foo
...
def xyz
# other stuff
ActiveSupport::Notifications.instrument(:interesting)
expensive_operation(123, 'apple') # We want to instrument this.
end
end
end我想做的是让另一个类Auditor在interesting事件引发时调用puts "event #{event}"。我该怎么做?
发布于 2011-02-01 16:47:27
一个很好的资源来自于railscast.com
http://railscasts.com/episodes/249-notifications-in-rails-3
您可以查看的另一个资源是Jose Valim的书“手工制作Rails应用程序”。
发布于 2012-07-13 03:32:18
这里有一些很好的资源可以让你入门:
的所有可用通知的列表
https://stackoverflow.com/questions/4367140
复制相似问题