benzelano / test_lh_import

1 stars 0 forks source link

after_transition callbacks don't get called when used with paranoid gem #60

Closed benzelano closed 13 years ago

benzelano commented 13 years ago

Mateo Murphy opened this issue

I’m trying to use the state_machine gem along with the paranoid gem, and for some reason after_transition callbacks are not getting called, even though the transition are succeeding; removing the "paranoid" macro from the model fixes the problem. From what I can tell by poking around with the code, it seems that the Transition objects are getting created with :after => false, but I haven’t figured out why, any ideas?

original LH ticket

This ticket has 0 attachment(s).

benzelano commented 13 years ago

Hi Mateo -

The paranoid gem still utilizes the old alias_method_chain technique for overriding methods in ActiveRecord (in particular, it overrides #create_or_update). Rails 3 has moved away from this practice in favor of using Ruby’s module inheritance chain (see the note in http://piotrsarnacki.com/2010/06/18/rails-internals-railties/). This is the technique that state_machine uses. The paranoid gem should be updated to this new "best practice".

benzelano commented 13 years ago

If you’re using Rails 3, state_machine should now work with the paranoid gem since it’s now using a different technique to hook into ActiveRecord. As such, marking as resolved.