You can see how Discourse does this internally in the PostCreator class:
So in your case, this should do:
t = Topic.find(123)
t.last_posted_at = t.posts.last.created_at
t.bumped_at = t.posts.last.created_at
t.save!
You can see how Discourse does this internally in the PostCreator class:
So in your case, this should do:
t = Topic.find(123)
t.last_posted_at = t.posts.last.created_at
t.bumped_at = t.posts.last.created_at
t.save!