has_many confuse

3 views
Skip to first unread message

Sydore

unread,
Oct 1, 2012, 6:36:44 AM10/1/12
to pai...@googlegroups.com
Hi Guys,

I have some issues with the below table relationship.

table_users
id
name

table_invoice
id
date

table_user_invoices
user_id
invoice_id

It doesn't seem to be easy way to manage the has_many for the above tables.

Looking forward for your advise.

Best Regards,
Sydore Pry


Chamnap Chhorn

unread,
Oct 1, 2012, 8:08:17 AM10/1/12
to pai...@googlegroups.com
Hi Sydore,

There are two ways to work out, many-to-many relationship, has_many :through, and has_and_belongs_to_many. Check out the differences in the Rails Guide.

In this case, I would suggest you to use has_and_belongs_to_many.

Cheers,
Chamnap




--
You received this message because you are subscribed to the Google Groups "Pailin (Cambodia Ruby/RubyOnRails User Group)" group.
To post to this group, send email to pai...@googlegroups.com.
To unsubscribe from this group, send email to pailin+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/pailin/-/JMGwYseEyI8J.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Chhorn Chamnap
http://chamnap.github.com/
Reply all
Reply to author
Forward
0 new messages