Hi everyone. I've been bending my head around a has_one association for about 3 hours now and I can't get it to work. I'm pretty sure it's not something I'm overlooking anymore. Here's the essential part of the schema I'm working with:

Code:
topics(id, last_post_id)
posts(id, topic_id)
Topics are simply named containers for posts. I decided not to use virtual tables since 99% of the columns would be topic-related. In the Topic model I have the following associations:

Code:
has_many(:posts)
has_one(:last_post, {:class_name => 'Post'})
Next, in the Post model, I have the following hook which should update the topic whenever a new post is added:

Code:
def after_create
  self.topic.last_post = self
end
Posts are added properly to the topics (@topic.posts << @post; @topic.save), yet somehow, every topic I add (1 post included) has NULL for the last_post_id. Please help, I'm losing my mind.