Ruby on Rails Monday, January 30, 2012

On Fri, Jan 27, 2012 at 14:36, rails_digger <chris@mckenzieic.com> wrote:

> I'm building a rails app that managed Member of a Group. There is a
> Member model and a Group model. Since a Member can belong to many
> Groups, and a Group can have many Member , there is a HABTM
> association between them.

Using HMT (has_many :through) rather than HABTM will make your whole
problem go away, with no need for worrying about threading, object
context, etc. (At least, any more than usual!)

Try using an association table, to represent a given member's
membership (hey, sounds like a good class name there!) in a group.
That's where you can put info like whether they're current on their
dues *for that group*, when they joined *that group*, etc. etc. etc.

-Dave

--
Dave Aronson:  Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com

--
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.

No comments:

Post a Comment