has_many :through

Hi Star, you should be able to do things that you need to do. The
:through allows you to have alot more flexibility in my opinion in the
event that you need to add additional field(s) to the join model.
Thus, you should be able to do the following with your current models:

message.user
message.message_users
message.users
message.users << user1
user.message_users
user.messages
user.messages << message1

Please revisit the AWDwRv2 for complete list of dynamically generated
methods using :through.

Good luck,

-Conrad

Hey Conrad, list...

So while it's true that using has_many :through does give you that
flexibility the fact that you now need to find a model for that join
table adds extra complexity to your domain model that you wouldn't
otherwise have with a standard habtm relationship. But your point is
well taken. If you think it's quite possible for your join table to
have additional attributes in the future making it a
has_many :through from the start saves you the pain of a data
migration later. But doing so as a manner of standard practice seems
to be overkill IMHO.

Best,

-Michael
http://javathehutt.blogspot.com

Your tables and classes look correct to me. Assuming that you are
creating your messages properly by adding the correct sender and
recipients your data should be returned correctly when you access
those relations. Write a unit test and see what is in the DB after
you send a single message so you can be sure things are behaving as
you suspect.

-Michael
http://javathehutt.blogspot.com