开发者

Rails3: Base#after_update has been deprecated

开发者 https://www.devze.com 2023-01-05 08:01 出处:网络
I see the warning: DEPRECATION WARNING: Base#after_update has been deprecated, please use Base.after_update :method ins开发者_高级运维tead. (called from <class:City> at /home/petrushka/webdev/m

I see the warning:

DEPRECATION WARNING: Base#after_update has been deprecated, please use Base.after_update :method ins开发者_高级运维tead. (called from <class:City> at /home/petrushka/webdev/my_app/app/models/city.rb:4)

What should I write instead of

  def after_update
     ....
  end


You should write as follow:

after_update :your_custom_method # macro-style

at least you can pass a block instead of a method:

after_update do |model| 
  model.name = model.name.capitalize unless model.name.blank?
end

more info here: http://guides.rails.info/active_record_validations_callbacks.html (choose rails edge documentation)

0

精彩评论

暂无评论...
验证码 换一张
取 消