Rails 3. Nested transactions. Exception in a child block
问题 Why doesn't ActiveRecord rollback changes in nested transactions after exception was risen in a child block? Here are examples: 1. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction do ?> Client.create(:name => 'Elena') >> raise ActiveRecord::Rollback >> end >> end => nil >> Client.all.map(&:name) => ["Pavel", "Elena"] # instead of [] 2. >> Client.transaction do ?> Client.create(:name => 'Pavel') >> Client.transaction(:requires_new => true) do ?> Client.create(