<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>README.rdoc</filename>
    </added>
    <added>
      <filename>attribute_fu.gemspec</filename>
    </added>
    <added>
      <filename>test/associated_form_helper_test.rb</filename>
    </added>
    <added>
      <filename>test/comment_test.rb</filename>
    </added>
    <added>
      <filename>test/db/.gitignore</filename>
    </added>
    <added>
      <filename>test/db/database.yml</filename>
    </added>
    <added>
      <filename>test/log/.gitignore</filename>
    </added>
    <added>
      <filename>test/models/comment.rb</filename>
    </added>
    <added>
      <filename>test/models/photo.rb</filename>
    </added>
    <added>
      <filename>test/photo_test.rb</filename>
    </added>
    <added>
      <filename>test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'rake'
+require &quot;load_multi_rails_rake_tasks&quot; 
 require 'rake/testtask'
 require 'rake/rdoctask'
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -54,7 +54,7 @@ module AttributeFu
       css_selector = options.delete(:selector) || &quot;.#{@object.class.name.split(&quot;::&quot;).last.underscore}&quot;
       function     = options.delete(:function) || &quot;&quot;
       
-      function &lt;&lt; &quot;$(this).up(&amp;quot;#{css_selector}&amp;quot;).remove()&quot;
+      function &lt;&lt; &quot;$(this).up('#{css_selector}').remove()&quot;
       
       @template.link_to_function(name, function, *args.push(options))
     end
@@ -89,7 +89,7 @@ module AttributeFu
       
       @template.link_to_function(name, opts) do |page|
         page &lt;&lt; &quot;if (typeof #{variable} == 'undefined') #{variable} = 0;&quot;
-        page &lt;&lt; &quot;new Insertion.Bottom(#{container}, new Template(&quot;+form_builder.render_associated_form(object, :fields_for =&gt; { :javascript =&gt; true }, :partial =&gt; partial).to_json+&quot;).evaluate({'number': --#{variable}}))&quot;
+        page &lt;&lt; &quot;new Insertion.Bottom(#{container}, new Template(&quot;+form_builder.render_associated_form(object, :fields_for =&gt; { :javascript =&gt; true }, :partial =&gt; partial).to_json+&quot;).evaluate({'number': --#{variable}}).gsub(/__number_/, #{variable}))&quot;
       end
     end
     </diff>
      <filename>lib/attribute_fu/associated_form_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -62,12 +62,14 @@ module AttributeFu
       def save_managed_associations #:nodoc:
         if managed_association_attributes != nil
           managed_association_attributes.keys.each do |association_id|
-            association = send(association_id)
-            association.each(&amp;:save)
+            if send(association_id).loaded? # don't save what we haven't even loaded
+              association = send(association_id)
+              association.each(&amp;:save)
 
-            unless (objects_to_remove = instance_variable_get removal_variable_name(association_id)).nil?
-              objects_to_remove.each { |remove_id| association.delete association.detect { |obj| obj.id.to_s == remove_id.to_s } }
-              instance_variable_set removal_variable_name(association_id), nil
+              unless (objects_to_remove = instance_variable_get removal_variable_name(association_id)).nil?
+                objects_to_remove.each { |remove_id| association.delete association.detect { |obj| obj.id.to_s == remove_id.to_s } }
+                instance_variable_set removal_variable_name(association_id), nil
+              end
             end
           end
         end
@@ -114,10 +116,20 @@ module AttributeFu
             discard_if = discard_if.to_proc if discard_if.is_a?(Symbol)
             managed_association_attributes[association_id][:discard_if] = discard_if
           end
+          collection_with_attributes_writer(association_id)
         end
         
         has_many_without_association_option(association_id, options, &amp;extension)
       end
+      
+    private
+    
+      def collection_with_attributes_writer(association_name)
+        define_method(&quot;#{association_name.to_s.singularize}_attributes=&quot;) do |attributes|
+          has_many_attributes association_name, attributes
+        end
+      end
+      
     end
     
   end # Associations</diff>
      <filename>lib/attribute_fu/associations.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,29 +1,16 @@
-# This file is auto-generated from the current state of the database. Instead of editing this file, 
-# please use the migrations feature of ActiveRecord to incrementally modify your database, and
-# then regenerate this schema definition.
-#
-# Note that this schema.rb definition is the authoritative source for your database schema. If you need
-# to create the application database on another system, you should be using db:schema:load, not running
-# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
-# you'll amass, the slower it'll run and the greater likelihood for issues).
-#
-# It's strongly recommended to check this file into your version control system.
-
 ActiveRecord::Schema.define(:version =&gt; 2) do
 
-  create_table &quot;comments&quot;, :force =&gt; true do |t|
-    t.integer  &quot;photo_id&quot;
-    t.string   &quot;author&quot;
-    t.text     &quot;body&quot;
-    t.datetime &quot;created_at&quot;
-    t.datetime &quot;updated_at&quot;
+  create_table :comments, :force =&gt; true do |t|
+    t.integer :photo_id
+    t.string :author
+    t.text :body
+    t.timestamps
   end
 
-  create_table &quot;photos&quot;, :force =&gt; true do |t|
-    t.string   &quot;title&quot;
-    t.text     &quot;description&quot;
-    t.datetime &quot;created_at&quot;
-    t.datetime &quot;updated_at&quot;
+  create_table :photos, :force =&gt; true do |t|
+    t.string :title
+    t.text   :description
+    t.timestamps
   end
 
 end</diff>
      <filename>test/db/schema.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>README</filename>
    </removed>
    <removed>
      <filename>test/Rakefile</filename>
    </removed>
    <removed>
      <filename>test/app/controllers/application.rb</filename>
    </removed>
    <removed>
      <filename>test/app/helpers/application_helper.rb</filename>
    </removed>
    <removed>
      <filename>test/app/models/comment.rb</filename>
    </removed>
    <removed>
      <filename>test/app/models/photo.rb</filename>
    </removed>
    <removed>
      <filename>test/config/boot.rb</filename>
    </removed>
    <removed>
      <filename>test/config/database.yml</filename>
    </removed>
    <removed>
      <filename>test/config/environment.rb</filename>
    </removed>
    <removed>
      <filename>test/config/environments/development.rb</filename>
    </removed>
    <removed>
      <filename>test/config/environments/test.rb</filename>
    </removed>
    <removed>
      <filename>test/config/routes.rb</filename>
    </removed>
    <removed>
      <filename>test/db/migrate/001_create_photos.rb</filename>
    </removed>
    <removed>
      <filename>test/db/migrate/002_create_comments.rb</filename>
    </removed>
    <removed>
      <filename>test/script/console</filename>
    </removed>
    <removed>
      <filename>test/script/destroy</filename>
    </removed>
    <removed>
      <filename>test/script/generate</filename>
    </removed>
    <removed>
      <filename>test/script/server</filename>
    </removed>
    <removed>
      <filename>test/test/test_helper.rb</filename>
    </removed>
    <removed>
      <filename>test/test/unit/associated_form_helper_test.rb</filename>
    </removed>
    <removed>
      <filename>test/test/unit/comment_test.rb</filename>
    </removed>
    <removed>
      <filename>test/test/unit/photo_test.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/init.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/lib/shoulda.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/lib/shoulda/context.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/lib/shoulda/general.rb</filename>
    </removed>
    <removed>
      <filename>test/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>c83f28d6489ef3f24017c4dee113db5f9c702407</id>
    </parent>
    <parent>
      <id>2184928876b6a99cf2aeab6f1f20caafef7975da</id>
    </parent>
  </parents>
  <author>
    <name>James Golick</name>
    <email>james@giraffesoft.ca</email>
  </author>
  <url>http://github.com/giraffesoft/attribute_fu/commit/adb3a4719c7fdf511255739adff4e3d86a53526b</url>
  <id>adb3a4719c7fdf511255739adff4e3d86a53526b</id>
  <committed-date>2008-11-25T06:12:29-08:00</committed-date>
  <authored-date>2008-11-25T06:12:29-08:00</authored-date>
  <message>Merge branch 'master' into jquery

Conflicts:

	lib/attribute_fu/associated_form_helper.rb
	test/associated_form_helper_test.rb</message>
  <tree>a88c518f8d15ec8715b3dddf1a56a25ad6f41d33</tree>
  <committer>
    <name>James Golick</name>
    <email>james@giraffesoft.ca</email>
  </committer>
</commit>
