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..
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().
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]) .
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.
There's a whole set of methods available for that. E.g., self.places_changed?
should work.
Check the docs for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With