<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,6 +25,7 @@ class PeopleController &lt; ApplicationController
   # GET /people/new.xml
   def new
     @person = Person.new
+    3.times { @person.phones.build }
 
     respond_to do |format|
       format.html # new.html.erb</diff>
      <filename>app/controllers/people_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,7 @@
 module PeopleHelper
+  def add_phone_link label
+    link_to_function label do |page|
+      page.insert_html :bottom, :phones, :partial =&gt; 'shared/phone', :object =&gt; Phone.new
+    end
+  end
 end</diff>
      <filename>app/helpers/people_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,30 @@
 class Person &lt; ActiveRecord::Base
-  has_many :phones
+  has_many :phones, :dependent =&gt; :destroy
+  after_update :save_phones
+  validates_associated :phones
 
   def name
     [self.first_name, self.last_name].join(&quot; &quot;)
   end
+
+  def phone_attributes=(phone_attributes)
+    phone_attributes.each do |attributes|
+      if attributes[:id].blank?
+        phones.build(attributes)
+      else
+        phone = phones.detect { |p| p.id == attributes[:id].to_i }
+        phone.attributes = attributes
+      end
+    end
+  end
+
+  def save_phones
+    phones.each do |p|
+      if t.should_destroy?
+        p.destroy
+      else
+        p.phone(false)
+      end
+    end
+  end
 end</diff>
      <filename>app/models/person.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,17 @@
 class Phone &lt; ActiveRecord::Base
   belongs_to :person
+  attr_accessor :should_destroy
 
-  validates_length_of :number, :is =&gt; 10
-  validates_inclusion_of :label, :in =&gt; [&quot;home&quot;, &quot;mobile&quot;, &quot;work&quot;, &quot;fax&quot;], :message =&gt; &quot;must be either 'home', 'mobile', 'work' or 'fax'&quot;
+  validates_length_of :number,
+    :is =&gt; 10,
+    :allow_nil =&gt; true
+
+  validates_inclusion_of :label,
+    :in =&gt; [&quot;home&quot;, &quot;mobile&quot;, &quot;work&quot;, &quot;fax&quot;],
+    :allow_nil =&gt; true,
+    :message =&gt; &quot;must be either 'home', 'mobile', 'work' or 'fax'&quot;
+
+  def should_destroy?
+    should_destroy.to_i == 1
+  end
 end</diff>
      <filename>app/models/phone.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,13 +21,13 @@
             &lt;li&gt;&lt;%= link_to 'List People', '/', :class =&gt; ('current' if (controller.controller_name == 'people' and controller.action_name == 'index')) %&gt;&lt;/li&gt;
             &lt;li&gt;&lt;%= link_to 'Add a Person', new_person_path, :class =&gt; ('current' if (controller.controller_name == 'people' and controller.action_name == 'new')) %&gt;&lt;/li&gt;
           &lt;%- if controller.controller_name == 'people' and controller.action_name == 'show' or controller.action_name == 'edit' -%&gt;
-            &lt;li&gt;&lt;%= link_to(@person.name, person_path(@person), :class =&gt; 'current') %&gt;&lt;/li&gt;
+            &lt;li&gt;&lt;%= link_to((controller.action_name == &quot;edit&quot; ? &quot;Editing &quot; : &quot;&quot;) + @person.name, person_path(@person), :class =&gt; 'current') %&gt;&lt;/li&gt;
           &lt;%- end -%&gt;
           &lt;/ul&gt;
         &lt;/div&gt;
       &lt;/div&gt;
 
-      &lt;div id=&quot;content&quot;&gt;
+      &lt;div id=&quot;content&quot; class=&quot;clearfix&quot;&gt;
     &lt;% if !flash.empty? %&gt;
       &lt;% flash.keys.each do |msgtype| %&gt;
         &lt;p class=&quot;flash_&lt;%= msgtype.to_s %&gt;&quot;&gt;&lt;%= flash[msgtype] %&gt;&lt;/p&gt;</diff>
      <filename>app/views/layouts/application.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -1,36 +1,48 @@
-&lt;h1&gt;Editing person&lt;/h1&gt;
-
 &lt;% form_for(@person) do |f| %&gt;
   &lt;%= f.error_messages %&gt;
 
+&lt;div id=&quot;form_container&quot; class=&quot;clearfix&quot;&gt;
+
+  &lt;div id=&quot;form_left&quot;&gt;
+    &lt;p&gt;
+      &lt;%= f.label :first_name %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :first_name %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :last_name %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :last_name %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :email %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :email %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :company_url %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :company_url %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :company %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :company %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :title %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :title %&gt;
+    &lt;/p&gt;
+  &lt;/div&gt;
+
+  &lt;div id=&quot;form_right&quot;&gt;
+    &lt;div id=&quot;phones&quot;&gt;
+  &lt;%= render :partial =&gt; 'shared/phone', :collection =&gt; @person.phones %&gt;
+    &lt;/div&gt;
+
+    &lt;%= add_phone_link &quot;Add a phone&quot; %&gt;
+  &lt;/div&gt;
+
+&lt;/div&gt;
+
+&lt;div id=&quot;controls&quot;&gt;
   &lt;p&gt;
-    &lt;%= f.label :first_name %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :first_name %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :last_name %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :last_name %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :email %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :email %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :company_url %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :company_url %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :company %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :company %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :title %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :title %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.submit &quot;Update&quot; %&gt;
+    &lt;%= f.submit &quot;Update&quot; %&gt; &lt;%= link_to 'Back', people_path %&gt;
   &lt;/p&gt;
-&lt;% end %&gt;
-
-&lt;%= link_to 'Show', @person %&gt; |
-&lt;%= link_to 'Back', people_path %&gt;
+&lt;/div&gt;
+&lt;% end %&gt;
\ No newline at end of file</diff>
      <filename>app/views/people/edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -3,33 +3,50 @@
 &lt;% form_for(@person) do |f| %&gt;
   &lt;%= f.error_messages %&gt;
 
+&lt;div id=&quot;form_container&quot; class=&quot;clearfix&quot;&gt;
+
+  &lt;div id=&quot;form_left&quot;&gt;
+    &lt;p&gt;
+      &lt;%= f.label :first_name %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :first_name %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :last_name %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :last_name %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :email %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :email %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :company_url %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :company_url %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :company %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :company %&gt;
+    &lt;/p&gt;
+    &lt;p&gt;
+      &lt;%= f.label :title %&gt;&lt;br /&gt;
+      &lt;%= f.text_field :title %&gt;
+    &lt;/p&gt;
+  &lt;/div&gt;
+
+  &lt;div id=&quot;form_right&quot;&gt;
+    &lt;div id=&quot;phones&quot;&gt;
+  &lt;%= render :partial =&gt; 'shared/phone', :collection =&gt; @person.phones %&gt;
+    &lt;/div&gt;
+
+    &lt;%= add_phone_link &quot;Add a phone&quot; %&gt;
+  &lt;/div&gt;
+
+&lt;/div&gt;
+
+&lt;div id=&quot;controls&quot;&gt;
   &lt;p&gt;
-    &lt;%= f.label :first_name %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :first_name %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :last_name %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :last_name %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :email %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :email %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :company_url %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :company_url %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :company %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :company %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.label :title %&gt;&lt;br /&gt;
-    &lt;%= f.text_field :title %&gt;
-  &lt;/p&gt;
-  &lt;p&gt;
-    &lt;%= f.submit &quot;Create&quot; %&gt;
+    &lt;%= f.submit &quot;Create&quot; %&gt; &lt;%= link_to 'Back', people_path %&gt;
   &lt;/p&gt;
+&lt;/div&gt;
 &lt;% end %&gt;
 
-&lt;%= link_to 'Back', people_path %&gt;
+</diff>
      <filename>app/views/people/new.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,7 @@
 // Place your application-specific JavaScript functions and classes here
 // This file is automatically included by javascript_include_tag :defaults
+
+function mark_for_destroy(element) {
+  $(element).next('.should_destroy').value = 1;
+  $(element).up('.task').hide();
+}
\ No newline at end of file</diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
    <modified>
      <diff>@@ -191,9 +191,35 @@ a:hover {
 
 
 
-/*****************/
+/******************/
 /*  Flash styles  */
-/*****************/
+/******************/
+
+div#form_container {
+  background: #EAEAEA;
+  border: 1px solid #909090;
+  width: 600px;
+  margin: 15px 0;
+  padding: 0 15px;
+  }
+
+div#form_left {
+  float: left;
+  }
+
+div#form_right {
+  float: left;
+  margin-left: 20px;
+  }
+
+div#controls {
+  clear: both;
+  }
+
+
+/******************/
+/*  Flash styles  */
+/******************/
 
 p.flash_notice,
 p.flash_error {</diff>
      <filename>public/stylesheets/default.css</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>public/.DS_Store</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>400af4b809bc9a0d96330e948f553365713658dc</id>
    </parent>
  </parents>
  <author>
    <name>Ryan L. Cross</name>
    <email>rcross@cylenceweb.com</email>
  </author>
  <url>http://github.com/cylence/spamstr-rails/commit/7f21864e4b11cfc19bb39aafa2e6b93e56769c5a</url>
  <id>7f21864e4b11cfc19bb39aafa2e6b93e56769c5a</id>
  <committed-date>2008-09-17T16:18:15-07:00</committed-date>
  <authored-date>2008-09-17T16:18:15-07:00</authored-date>
  <message>Committing unfinished changes to People New/Edit forms</message>
  <tree>9d20ace3db8512a388dbef4127b58eb2a591d8ea</tree>
  <committer>
    <name>Ryan L. Cross</name>
    <email>rcross@cylenceweb.com</email>
  </committer>
</commit>
