How to tell both User and Topic, that a new Message has been created?
I can do: @user.messages << @message, but what to do to notify the
@topic? Is it possible to do that in a pretty manner?
Can you not just do @topic.messages << @message
Are you sure you have your relationships right? For example does the
topic that a message belongs to also belong to the same user? If so
then for user you want has_many through on one of them, through the
other.
But to update the counter columns, then rails does 2 redundant select
queries: one for topic and one for user then updates the counter
columns, although user and topic objects are already available.
I could code that manually but it doesn't look pretty. I think some time
ago Fred Cheung said that intelligent reserve associations would be
available in Rails 3, for now rails has to do redundant selects in order
to update the objects. Maybe there is another and better way to achieve
what I want?