 				$throw(type="Wheels.AssociationNotFound", message="The assocation `#loc.association#` was not found on the #variables.wheels.class.modelName# model.", extendedInfo="Make sure your have call `hasMany()`, `hasOne()`, or `belongsTo()` before calling the `nestedAttributesFor()` method.");
 			}
 		}
-
-		afterCreate(method="$saveAssociations"); // we need an after create so that we have the top objects id for setting foreign key values
+		
+		afterCreate(method="$saveAssociations"); // we need transactional support for after callbacks so this does not create an object and then the associations fail
 		beforeUpdate(method="$saveAssociations");
 	</cfscript>
 </cffunction>
 
 <cffunction name="$saveAssociations" returntype="boolean" access="public" output="false">
+	<cfargument name="associations" type="struct" required="false" default="#variables.wheels.class.associations#" />
 	<cfscript>
 		var loc = {};
 		loc.returnValue = true;
-		for (loc.association in variables.wheels.class.associations)
-		{
-			if (variables.wheels.class.associations[loc.association].nested.allow)
-			{
-				if (StructKeyExists(this, loc.association))
+		for (loc.association in arguments.associations)
+		{
+			if (arguments.associations[loc.association].nested.allow && arguments.associations[loc.association].nested.autoSave && StructKeyExists(this, loc.association))
+			{
+				loc.array = this[loc.association];
+				
+				if (IsObject(this[loc.association]))
+					loc.array = [ this[loc.association] ];
+			
+				if (IsArray(loc.array))
 				{
-					loc.array = this[loc.association];
-
-					if (IsObject(this[loc.association]))
-						loc.array = [ this[loc.association] ];
-
-					if (IsArray(loc.array))
+					// get our expanded information for this association
+					loc.info = $expandedAssociations(include=loc.association);
+					loc.info = loc.info[1];
+				
+					loc.iEnd = ArrayLen(loc.array);
+					for (loc.i = 1; loc.i lte loc.iEnd; loc.i++)
 					{
-						// get our expanded information for this association
-						loc.info = $expandedAssociations(include=loc.association);
-						loc.info = loc.info[1];
-
-						loc.iEnd = ArrayLen(loc.array);
-						for (loc.i = 1; loc.i lte loc.iEnd; loc.i++)
-						{
-							if (ListFindNoCase("hasMany,hasOne", variables.wheels.class.associations[loc.association].type))
-								$setForeignKeyValues(missingMethodArguments=loc.array[loc.i], keys=loc.info.foreignKey);
-							loc.saveResult = loc.array[loc.i].save();
-							if (loc.returnValue) // don't change the return value if we have already received a false
-								loc.returnValue = loc.saveResult;
-						}
+						if (ListFindNoCase("hasMany,hasOne", arguments.associations[loc.association].type))
+							$setForeignKeyValues(missingMethodArguments=loc.array[loc.i], keys=loc.info.foreignKey);
+						loc.saveResult = loc.array[loc.i].save();
+						if (loc.returnValue) // don't change the return value if we have already received a false
+							loc.returnValue = loc.saveResult;
 					}
 				}
 			}


<cffunction name="$setCollectionAssociationProperty" returntype="void" access="public" output="false">
	<cfargument name="property" type="string" required="true" />
	<cfargument name="value" type="array" required="true" />
	<cfargument name="association" type="struct" required="true" />
	<cfscript>
		var loc = {};

		this[arguments.property] = [];

		loc.iEnd = ArrayLen(arguments.value);
		for (loc.i = 1; loc.i lte loc.iEnd; loc.i++)
		{
			ArrayAppend(this[arguments.property], $getAssociationObject(property=arguments.property, value=arguments.value[loc.i], association=arguments.association));

			loc.position = ArrayLen(this[arguments.property]);
			if (IsObject(this[arguments.property][loc.position]))
				this[arguments.property][loc.position].setProperties(properties=arguments.value[loc.i]);
			else
				ArrayDeleteAt(this[arguments.property], loc.position);
		}
	</cfscript>
	<cfreturn />
</cffunction>

<cffunction name="$getAssociationObject" returntype="any" access="public" output="false">

	<cfscript>
		var loc = {};
		loc.returnValue = "";
		
		loc.iEnd = ListLen(arguments.keys);
		for (loc.i = 1; loc.i lte loc.iEnd; loc.i++)
		{
			loc.key = ListGetAt(arguments.keys, loc.i);
			if (!StructKeyExists(arguments.params, loc.key) || !Len(arguments.params[loc.key]))
				return "";
			loc.returnValue = ListAppend(loc.returnValue, arguments.params[loc.key]);	
		}
	</cfscript>
	<cfreturn loc.returnValue />
