IRB Rocks!

# Hack your code

Update timestamp of a model in Rails

Recently I need to update timestamps of a model because I use this value as "last seen". In a Job, I update a model or others associated to it, so in the second case, I need to update timestamps.

Instead of use model.update(update_at: Time.now), Rails provide us with touch method to perform this task:

# Update update_at with current time
model.touch
# Update last_seen
model.touch(:last_seen)

gem share .gem