Can someone please point me to the right direction.
I’m using after_validation to compete geocoding and I wanted to know how I can tact on an or || option to an if clause.
This works as intended
class Address < ActiveRecord::Base
after_validation :geocode, if: :address_changed?
But this doesn’t
class Address < ActiveRecord::Base
after_validation :geocode, if: :address_changed? || :zipcode_changed?
Thanks in advance.
If you don’t want to use Thilo’s
Procapproach then you can add your own custom method and use that:This may (or may not) read better and is handy if you need the same compound condition on multiple validations.