Thursday, October 28, 2010

[Rails] Many to many AND one to many association

I want create mini mail service in my website, but i have little
problem mapping assotiation.
I have two models User and Message, every message have one sender and
many recievers.
I map sender with user_id field in message and recievers with table
messagesusers with user_id and message_id fields.
In model message I add
belongs_to :user
has_many :users
and in messagesuser
belongs_to :user
belongs_to :message
I don't know what add in user model, i try with
has_many :messages
but doesn't work.
Thanks and sorry for my poor english

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate