Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


before_transition works, after_transition fails on Rails 4/Mongoid #277

nofxx opened this Issue · 18 comments

Lost some time on this one... only here?
As 'fails' I mean wont run, tryed some raise() there and nothing happens.

class Order
  include Mongoid::Document

  state_machine :state, :initial => :created do

    before_transition :on => :pay do |o|
    #... WORKS!

    after_transition :on => :pay do |o|
    # ... NOTHING


Rails 4, Mongoid 4


+1 Anyone got any idea how to quick fix this?




Somehow this commit is breaking the after_transition callback mongoid/mongoid@8c23304


hi @aganov is it still pending pull request ? I just stucked with the same issue. after_transition doesn't fire up. Can we get it merged ?


@aganov @pluginaweek Any chance that this will get merged soon?


Also ran into this bug, would be great to get a fix merged.


@aganov @pluginaweek Is there any way I can help getting this fixed?


@aganov I've confirmed that that fix works, but the pull is probably not mergable yet since there's no test for the fix. I'd be happy to see if I can help with that?


+1 for tests and merge


If somebody creates a good pull request for this, will it get merged? Mongoid 4 release is getting pretty close and it would be good to have this in an official release.

cc @aganov @pluginaweek


I could reproduce the same behavior. Before transition is working, while after is not called. Really appreciate for the fix.

@blakefrost blakefrost referenced this issue from a commit in blakefrost/newstime
@blakefrost blakefrost Implement full cycle compile with real time update
State machine after_transition hook with mongoid was not working. Issue is
documented here pluginaweek/state_machine#277

Used the version of state_machine from,
referenced in the github issue, to get things working for the time being.

I'm using the transtion to trigger the broadcast of the update to the compiled

+1 please




Have an idea about mainaining #331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.