title: Rails 3 Transactions, Rolling Back Everything
body: <pre><code>class Bear &lt; ActiveRecord::Base
      def feed!
        self.transaction do
            raise Exception unless self.foods_eaten &lt;&lt; Food.new(:name =&gt; "fish")
            self.fed_at = Time.now
            save!
         end
      end
  end
  
  class Hippo &lt; ActiveRecord::Base
      def wash!
          self.transaction do
              @soap.inventory -= 1
              @soap.save!
              self.washed_at = Time.now
              save!
          end
      end
  end
  
  class ZookeeperController &lt; ApplicationController
  
      def chores
          @zookeeper = Zookeeper.find(params[:id])
          Animal.transaction do
              begin
                  @hippo.wash!
                  @bear.feed!    # =&gt; FAIL AT THIS LINE
                  @zookeeper.finished_at = Time.now
                  @zookeeper.save!
                  redirect_to chores_completed_path
              rescue Exception =&gt; e
                   render "new_chores"
              end
          end
      end
  end
  </code></pre>
  
  <p>If <code>Zookeeper#chores</code> gets invoked and <code>@bear.feed!</code> fails and raises an exception, then will everything rollback?</p>
  
  <p>Any other suggestions on how to improve this code are also welcome.</p>