+
+ # If expires_at is being changed to a time in the past, change it to
+ # now. This allows clients to say "expires {client-current-time}"
+ # without failing due to clock skew, while avoiding odd log entries
+ # like "expiry date changed to {1 year ago}".
+ def expires_at_not_in_past
+ if expires_at_changed? and expires_at
+ self.expires_at = [db_current_time, expires_at].max
+ end
+ end