muscardinus
muscardinus

Reputation: 689

Ruby on Rails: How to get the model/table modification time

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

Answers (2)

Holger Just
Holger Just

Reputation: 55718

Easy, just use the ActiveRecord-provided maximum method, like so

MyModel.maximum(:updated_on)

Upvotes: 1

mu is too short
mu is too short

Reputation: 434606

Use the maximum class method on your model:

whole_table_updated_at = YourModel.maximum('updated_at')

Upvotes: 3

Related Questions