2009/9/29 Fernando Perez <[email protected]>:
>
> Let's say I have the following models:
>
> User, has_many :messages, :topics
> Forum, has_many :topics
> Topic, belongs_to :user, has_many :messages

Topic is missing a belongs_to :Forum

> Message, belongs_to :user, :topic
>
> 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.

Colin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to