Closed DanielWright closed 9 years ago
Hi @DanielWright, the second approach sounds sensible. I'd be in favour of keeping the current behaviour as default (it's correct 99% of the time), but having the association_name
available as an override. Look forward to the PR!
Closing now #131 is merged and included in a release. Thanks again @DanielWright !
Hi there,
I'm having some difficulty implementing Statesman with namespaced ActiveRecord models. The root cause, I've discovered, is the Stateman ActiveRecord adapter relies on the transition model's
table_name
exactly matching its has_many association to the parent model.In the following example, this falls apart:
I considered proposing a pull request that reflects on the parent model's associations and tries to infer the transitions association via tortured comparison with
@transition_class.model_name
. However, I realized even that inference would break down if the transition-class's table-name doesn't match the association for whatever reason.I propose instead adding another configuration option to
Statesman::Machine
's initializer, something likeassociation_name
, which can be passed down to the adapter and sent to the parent model to retrieve the transitions collection. I'm working on a PR, but I'd appreciate any feedback on the idea before I go too far down that road.Thanks!