我看到警告:
DEPRECATION WARNING: Base#after_update has been deprecated, please use Base.after_update :method instead. (called from <class:City> at /home/petrushka/webdev/my_app/app/models/city.rb:4)
我应该写什么而不是
def after_update
....
end
答案 0 :(得分:10)
你应该写如下:
after_update :your_custom_method # macro-style
至少你可以传递一个块而不是一个方法:
after_update do |model|
model.name = model.name.capitalize unless model.name.blank?
end
此处提供更多信息:http://guides.rails.info/active_record_validations_callbacks.html(选择rails edge文档)