{"action":"created","issue":{"url":"https://api.github.com/repos/aasm/aasm/issues/313","repository_url":"https://api.github.com/repos/aasm/aasm","labels_url":"https://api.github.com/repos/aasm/aasm/issues/313/labels{/name}","comments_url":"https://api.github.com/repos/aasm/aasm/issues/313/comments","events_url":"https://api.github.com/repos/aasm/aasm/issues/313/events","html_url":"https://github.com/aasm/aasm/issues/313","id":128424259,"number":313,"title":"'after_commit' on event not firing after record is saved and committed","user":{"login":"chinshr","id":29537,"avatar_url":"https://avatars.githubusercontent.com/u/29537?v=3","gravatar_id":"","url":"https://api.github.com/users/chinshr","html_url":"https://github.com/chinshr","followers_url":"https://api.github.com/users/chinshr/followers","following_url":"https://api.github.com/users/chinshr/following{/other_user}","gists_url":"https://api.github.com/users/chinshr/gists{/gist_id}","starred_url":"https://api.github.com/users/chinshr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chinshr/subscriptions","organizations_url":"https://api.github.com/users/chinshr/orgs","repos_url":"https://api.github.com/users/chinshr/repos","events_url":"https://api.github.com/users/chinshr/events{/privacy}","received_events_url":"https://api.github.com/users/chinshr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"alto","id":3209,"avatar_url":"https://avatars.githubusercontent.com/u/3209?v=3","gravatar_id":"","url":"https://api.github.com/users/alto","html_url":"https://github.com/alto","followers_url":"https://api.github.com/users/alto/followers","following_url":"https://api.github.com/users/alto/following{/other_user}","gists_url":"https://api.github.com/users/alto/gists{/gist_id}","starred_url":"https://api.github.com/users/alto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alto/subscriptions","organizations_url":"https://api.github.com/users/alto/orgs","repos_url":"https://api.github.com/users/alto/repos","events_url":"https://api.github.com/users/alto/events{/privacy}","received_events_url":"https://api.github.com/users/alto/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-01-24T20:51:54Z","updated_at":"2016-02-05T00:28:26Z","closed_at":"2016-02-05T00:28:26Z","body":"When I am saving an instance after I changed the state with event (without bang), I am not receiving an `after_commit` callback, if I do the same with the bang, it works. Example:\r\n\r\n```ruby\r\nclass Job < ActiveRecord::Base\r\n  include AASM\r\n  aasm column: 'aasm_state' do\r\n    state :started, initial: true\r\n    state :stopping\r\n\r\n    event :stop, :after_commit => :after_commit_event_stop do\r\n      transitions :from => :started, :to => :stopping\r\n    end\r\n  ...\r\n  end\r\n\r\n  def after_commit_event_stop\r\n    puts \"Not firing!\"\r\n  end\r\nend\r\n\r\n#  Create and stop a job\r\n@job = Job.create\r\n@job.event = :stop\r\n@job.save\r\n# Notice: after_commit_event_stop is not firing\r\n```\r\n\r\nNote: aasm, \"~> 4.7\""},"comment":{"url":"https://api.github.com/repos/aasm/aasm/issues/comments/180122281","html_url":"https://github.com/aasm/aasm/issues/313#issuecomment-180122281","issue_url":"https://api.github.com/repos/aasm/aasm/issues/313","id":180122281,"user":{"login":"alto","id":3209,"avatar_url":"https://avatars.githubusercontent.com/u/3209?v=3","gravatar_id":"","url":"https://api.github.com/users/alto","html_url":"https://github.com/alto","followers_url":"https://api.github.com/users/alto/followers","following_url":"https://api.github.com/users/alto/following{/other_user}","gists_url":"https://api.github.com/users/alto/gists{/gist_id}","starred_url":"https://api.github.com/users/alto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alto/subscriptions","organizations_url":"https://api.github.com/users/alto/orgs","repos_url":"https://api.github.com/users/alto/repos","events_url":"https://api.github.com/users/alto/events{/privacy}","received_events_url":"https://api.github.com/users/alto/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T00:28:26Z","updated_at":"2016-02-05T00:28:26Z","body":"@chinshr The only explanation is that it has nothing to do with _ActiveRecord_ `after_commit` hooks. It only shares the name, not the behaviour. It's basically a _do this –for the currently triggered event– if and when the change has been committed to the database_. Saying this, it's totally event-based. A pure _ActiveRecord_ `save` (including all manual changes you did) is not going through any other _AASM_ callbacks either. An event trigger without `!` (bang) fires all callbacks that are not related to persisting the state change, as it doesn't persist the state. "}}