Topic: [SOLVED] How to implement HABTM with shared attributes

I have a Courses Model and a Users model. I want Users to be able to have many courses and vice versa for courses, but I also need to track the state of the relationship (with state_machine and a state:string column on the join table). According to the rails guide on AR associations, having extra columns on the join table is deprecated.

What's the recommended way to do this? Should I do has_many :through on both?

Last edited by gorrillamcd (2012-05-04 18:32:55)

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? | techonamission.com

Re: [SOLVED] How to implement HABTM with shared attributes

Well, I answered my own question. I was for some reason thinking has_many :through was a one-to-many association, but it can and should be used in my required case. I tell you what, I'm glad I found out about state machines too. It way better than managing a bunch of booleans.

Change is a vector. You can have all the change in the world, but if it doesn't go in the right direction, what good is it? | techonamission.com