Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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..

like image 552
stuartchaney Avatar asked Dec 14 '10 20:12

stuartchaney


People also ask

How do I check for a column update in SQL?

Using a SQL Server trigger to check if a column is updated, there are two ways this can be done; one is to use the function update(<col name>) and the other is to use columns_updated().

How do you check if a value is present in a column in Excel?

You can use the MATCH() function to check if the values in column A also exist in column B. MATCH() returns the position of a cell in a row or column. The syntax for MATCH() is =MATCH(lookup_value, lookup_array, [match_type]) .

How do you check if a value is present in a table?

To test whether a row exists in a MySQL table or not, use exists condition. The exists condition can be used with subquery. It returns true when row exists in the table, otherwise false is returned. True is represented in the form of 1 and false is represented as 0.


1 Answers

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

Check the docs for more.

like image 99
Nikita Rybak Avatar answered Sep 28 '22 12:09

Nikita Rybak