Forum: Ruby on Rails Populating associations

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Simon M. (Guest)
on 2008-12-23 04:00
(Received via mailing list)
Hi all,

I have a Message class which has_many Message_Users, Message_User is
basically a join table with an attribute, and belongs_to a User.

so it kinda looks like the following:

Message has_many :message_users

MessageUser belong_to :user

User - lots of user stuff

What I want to do, is on the Message create screen have a list box with
all the users in it, and when the Message is created have it
create 1 MessageUser for each user selected, and link them to the new
Message through the MessageUser association. Is this possible, or do I
need to grab the list of users selected and manually create the
Or can anyone see a better way to set up the structures?

Hope the question is clear.
TomRossi7 (Guest)
on 2008-12-23 23:40
(Received via mailing list)
You may want to check out this blog post.  I think it may help with
what you are looking to do:
This topic is locked and can not be replied to.