<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,8 +1,10 @@
 # save and validation support for associations.
 class ActiveRecord::Base
-  def associated_valid?
+  def associated_valid?(path = [])
+    return true if path.include?(self) # prevent recursion (if associated and parent are new records)
+    path &lt;&lt; self
     # using [].all? syntax to avoid a short-circuit
-    with_unsaved_associated { |a| [a.valid?, a.associated_valid?].all? {|v| v == true} }
+    with_unsaved_associated { |a| [a.valid?, a.associated_valid?(path)].all? {|v| v == true} }
   end
 
   def save_associated</diff>
      <filename>lib/extensions/unsaved_associated.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e38b2381baf24ed58df64719da324a9c1559b6a7</id>
    </parent>
  </parents>
  <author>
    <name>Tim Harper</name>
    <email>timcharper@gmail.com</email>
  </author>
  <url>http://github.com/activescaffold/active_scaffold/commit/1e6a79b926729c4d27a1e5d0b9b24b0df6fface8</url>
  <id>1e6a79b926729c4d27a1e5d0b9b24b0df6fface8</id>
  <committed-date>2008-06-29T01:04:59-07:00</committed-date>
  <authored-date>2008-06-29T00:15:02-07:00</authored-date>
  <message>fixed infinite recursion issue in demo

associated_valid? would get stuck in an infinite loop if creating two new associated records in the same save transaction.</message>
  <tree>a2cc4fa9e3fd7a3f0b7fb6d14d09aae5c67908fa</tree>
  <committer>
    <name>Tim Harper</name>
    <email>timcharper@gmail.com</email>
  </committer>
</commit>
