Reputation: 1695
I have a column with name points
in my Users table. Is there any simple way to get the date and time at which this column for a particular user was updated in Ruby on Rails.
Upvotes: 1
Views: 187
Reputation: 490
Add one more column points_update_at in User table and add call back
before_update {|u|
points_update_at = Time.now if u.points_changed?
}
Upvotes: 2
Reputation: 10593
No, you can check updated_at
but it will change after any update on record.
Only good solution to that problem is to add another column, let's call it points_updated_at
and add a callback to change it value if points
is changed.
before_save do
self.points_updated_at = Time.now if self.points_changed?
end
Upvotes: 4