stuartchaney
stuartchaney

Reputation: 432

Seeing if a column value is updated

I have a complex user model with a validation method

before_validation_on_update :geocode_places

This validation geocodes the "places" column in my user table each time an update occurs.

The problem is that this validation takes quite a long time. Is there any way to only call this validation when the places column is updated? Sort of like a "before_validation_on_column_update" so to speak..

Upvotes: 6

Views: 326

Answers (1)

Nikita Rybak
Nikita Rybak

Reputation: 67996

There's a whole set of methods available for that. E.g., self.places_changed? should work.

Check the docs for more.

Upvotes: 8

Related Questions