{"action":"created","issue":{"url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/16","labels_url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/16/comments","events_url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/16/events","html_url":"https://github.com/state-machines/state_machines-activerecord/issues/16","id":70716437,"number":16,"title":"use_transactions: false not respected in execution","user":{"login":"rosskevin","id":136564,"avatar_url":"https://avatars.githubusercontent.com/u/136564?v=3","gravatar_id":"","url":"https://api.github.com/users/rosskevin","html_url":"https://github.com/rosskevin","followers_url":"https://api.github.com/users/rosskevin/followers","following_url":"https://api.github.com/users/rosskevin/following{/other_user}","gists_url":"https://api.github.com/users/rosskevin/gists{/gist_id}","starred_url":"https://api.github.com/users/rosskevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosskevin/subscriptions","organizations_url":"https://api.github.com/users/rosskevin/orgs","repos_url":"https://api.github.com/users/rosskevin/repos","events_url":"https://api.github.com/users/rosskevin/events{/privacy}","received_events_url":"https://api.github.com/users/rosskevin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-24T15:17:45Z","updated_at":"2015-04-24T15:25:39Z","closed_at":null,"body":"I should note that I am debugging this in a `before_transition`.\r\n\r\nI'm not sure what is going on yet, but I can see that the [machine.rb#within_transaction](https://github.com/state-machines/state_machines/blob/master/lib/state_machines/machine.rb#L1862) is not run (which seems to evaluate this flag).   With the active record integration, it runs the transaction every time.  I'm not sure if it is overwriting that check in machine or what is occuring, but I cannot seem to turn off transactions as [this code](https://github.com/state-machines/state_machines-activerecord/blob/master/lib/state_machines/integrations/active_record.rb#L536) is always run:\r\n\r\n```ruby\r\n      # Runs a new database transaction, rolling back any changes by raising\r\n      # an ActiveRecord::Rollback exception if the yielded block fails\r\n      # (i.e. returns false).\r\n      def transaction(object)\r\n        result = nil\r\n        object.class.transaction do\r\n          raise ::ActiveRecord::Rollback unless result = yield\r\n        end\r\n        result\r\n      end\r\n```\r\n\r\nThe state_machine is configured with:\r\n\r\n```ruby\r\n    state_machine :state, initial: :uninitialized, use_transactions: false do\r\n```"},"comment":{"url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/comments/95965763","html_url":"https://github.com/state-machines/state_machines-activerecord/issues/16#issuecomment-95965763","issue_url":"https://api.github.com/repos/state-machines/state_machines-activerecord/issues/16","id":95965763,"user":{"login":"rosskevin","id":136564,"avatar_url":"https://avatars.githubusercontent.com/u/136564?v=3","gravatar_id":"","url":"https://api.github.com/users/rosskevin","html_url":"https://github.com/rosskevin","followers_url":"https://api.github.com/users/rosskevin/followers","following_url":"https://api.github.com/users/rosskevin/following{/other_user}","gists_url":"https://api.github.com/users/rosskevin/gists{/gist_id}","starred_url":"https://api.github.com/users/rosskevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rosskevin/subscriptions","organizations_url":"https://api.github.com/users/rosskevin/orgs","repos_url":"https://api.github.com/users/rosskevin/repos","events_url":"https://api.github.com/users/rosskevin/events{/privacy}","received_events_url":"https://api.github.com/users/rosskevin/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T15:25:39Z","updated_at":"2015-04-24T15:25:39Z","body":"[`#around_save`](https://github.com/state-machines/state_machines-activerecord/blob/master/lib/state_machines/integrations/active_record.rb#L509) appears to be the culprit.  No check for the flag, just use the transaction.  It may not be checking for the flag because there could be one or more state_machines in this block:\r\n\r\n```ruby\r\n      # Runs state events around the machine's :save action\r\n      def around_save(object)\r\n        transaction(object) do\r\n          object.class.state_machines.transitions(object, action).perform { yield }\r\n        end\r\n      end\r\n```"}}