Reputation: 689
I know every row has its timestamp (modified_at), but I would like to get the time of the latest modification (row added/modified/deleted) of the database table.
I have a daemon running in the background that needs to periodically check if a table has changed.
So far, I haven't found a way to do this.
Upvotes: 0
Views: 644
Reputation: 55718
Easy, just use the ActiveRecord-provided maximum
method, like so
MyModel.maximum(:updated_on)
Upvotes: 1
Reputation: 434606
Use the maximum
class method on your model:
whole_table_updated_at = YourModel.maximum('updated_at')
Upvotes: 3