Closed dannguyen closed 10 years ago
The more that I think about it, the more it seems that the state machine should be placed on VettingProcess, right?
Correct. Use a has_many :through
instead of a hbtm and you can easily put the state machine on the join model. No need for any special logic.
I've browsed the documentation and some of the source and didn't see this directly addressed...but here's a hypothetical use case:
I have
People
andOrganizations
, and eachperson
has a certain state with eachorganization
. Let's pretend it's something like a vetting process, and you want to formalize the state of how each organization has vetted each person.To simplify things, the vetting state machine for each organization can be the same. You might have the states be something like:
So given that a person may be vetted by a variable number of organizations, it is unwieldy to store the state as a column in the
people
table. It seems that it requires an intermediary model, such as VettingProcess, so that aperson
can have manyvetting_processes
withorganizations
and vice versa.The more that I think about it, the more it seems that the state machine should be placed on VettingProcess, right? So I suppose what I'm asking for is if there's a convention for this, but the more I think about it, that seems needlessly outside the scope of this gem, but doesn't hurt to ask :)