Rails3: base # after_update is deprecated

I see a warning:

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)

What should I write instead

  def after_update
     ....
  end
+5
source share
1 answer

You should write the following:

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 details here: http://guides.rails.info/active_record_validations_callbacks.html (select rail documentation)

+10
source

All Articles