我有一个User模型,其中包含模块Staff:
class User < ActiveRecord::Base
include Staff
...
end
我想为包含此模块的所有模型添加after_update回调:
module Staff
def self.included(model)
model.class_eval do
after_update :callback
end
end
private
def callback
...
end
end
我得到NoMethodError:
undefined method `after_update' for Object:Class
我做错了什么?
答案 0 :(得分:0)
解决! 问题是我有另一个类,包括我的模块Staff,它不是ActiveRecord模型。