<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,14 +3,14 @@
 
 %tr{:id =&gt; &quot;page-attribute-#{page_attribute_row_counter}&quot;}
   %th.label
-    %label{:for =&gt; &quot;page_build_page_attributes__#{page_attribute_row_counter}_class_name&quot;}
+    %label{:for =&gt; &quot;page_page_attributes__#{page_attribute_row_counter}_value&quot;}
       = page_attribute_row.name
       %small.info
         = &quot;(#{page_attribute_row.class.display_name})&quot;
-      - fields_for &quot;page[build_page_attributes][#{page_attribute_row_counter}]&quot; do |attribute|
+      - fields_for &quot;page[page_attributes][#{page_attribute_row_counter}]&quot; do |attribute|
         = attribute.hidden_field :class_name, :value =&gt; page_attribute_row.class_name
         = attribute.hidden_field :name, :value =&gt; page_attribute_row.name
   %td.field
-    - fields_for &quot;page[build_page_attributes][#{page_attribute_row_counter}]&quot; do |attribute|
+    - fields_for &quot;page[page_attributes][#{page_attribute_row_counter}]&quot; do |attribute|
       = render :partial =&gt; &quot;/admin/page_attributes/#{page_attribute_row.class.partial_name}&quot;, :locals =&gt; { :attribute =&gt; attribute, :page_attribute =&gt; page_attribute_row }
     = link_to_function image('minus', :alt =&gt; 'minus'), %{if(confirm('Delete this attribute?')) { page_attribute_removed('page-attribute-#{page_attribute_row_counter}') }}, :title =&gt; 'Remove Attribute'</diff>
      <filename>app/views/admin/page_attributes/_page_attribute_row.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 module PageAttributes
   module PageExtensions
-    
+
     def self.included(base)
       base.class_eval do
         has_many :page_attributes, :dependent =&gt; :destroy do
@@ -10,17 +10,36 @@ module PageAttributes
             end
           end
         end
+        after_save :save_page_attributes
+        alias_method_chain :page_attributes, :pending
+        alias_method_chain :page_attributes=, :pending
       end
     end
-    
-    def build_page_attributes=(args={})
-      self.page_attributes.destroy_all
-      args.each_pair do |i,hash|
-        attr = self.page_attributes.build(hash)
-        attr.page = self
+      
+    def page_attributes_with_pending(reload=false)
+      @page_attrs = nil if reload
+      @page_attrs || page_attributes_without_pending(reload)
+    end
+
+    def page_attributes_with_pending=(collection)
+      if collection.values.all? {|item| item.is_a? PageAttribute }
+        self.page_attributes_without_pending = collection.values
+      else
+        self.updated_at_will_change!
+        @page_attrs = collection.values.map { |item| PageAttribute.new(item.merge(:page =&gt; self)) }
       end
-      self.page_attributes
     end
-     
+
+    private
+
+      def save_page_attributes
+        if @page_attrs
+          self.page_attributes_without_pending.clear
+          @page_attrs.each {|p| self.page_attributes_without_pending &lt;&lt; p }
+        end
+        @page_attrs = nil
+        true
+      end
+
   end
 end
\ No newline at end of file</diff>
      <filename>lib/page_attributes/page_extensions.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>e92ac21e454f43c06d7bd60e1e89d5e47e3e1bfd</id>
    </parent>
  </parents>
  <author>
    <name>Josh French</name>
    <email>josh@vitamin-j.com</email>
  </author>
  <url>http://github.com/jfrench/radiant-page-attributes/commit/6ddb1525f31ce4ebd87dd30a37addcd190f889e8</url>
  <id>6ddb1525f31ce4ebd87dd30a37addcd190f889e8</id>
  <committed-date>2009-03-21T12:54:23-07:00</committed-date>
  <authored-date>2009-03-21T12:54:23-07:00</authored-date>
  <message>Steal the nice PageParts pattern</message>
  <tree>3dce8edf578a2f551594b1b5b18a71ace460ba73</tree>
  <committer>
    <name>Josh French</name>
    <email>josh@vitamin-j.com</email>
  </committer>
</commit>
