<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/addresses/confirm_destroy.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 class AddressesController &lt; ApplicationController
-  before_filter :current_address, :only =&gt; [:show, :edit, :update, :destroy]
+  before_filter :current_address, :only =&gt; [:show, :edit, :update, :destroy, :confirm_destroy]
   def index
     if params[:customer_id].blank?
       @addresses = current_user.user_addresses
@@ -76,6 +76,9 @@ class AddressesController &lt; ApplicationController
     end
   end
   
+  def confirm_destroy    
+  end
+  
   private
   def current_address
     if params[:customer_id]</diff>
      <filename>app/controllers/addresses_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 class InvoicesController &lt; ApplicationController
 
-  before_filter :current_invoice, :only =&gt; [:show, :edit, :destroy, :confirm_destroy, :update]
+  before_filter :current_invoice, :only =&gt; [:show, :edit, :update, :destroy, :confirm_destroy]
 
   require 'fpdf'
   load 'fpdf_table.rb'</diff>
      <filename>app/controllers/invoices_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -38,11 +38,9 @@ module ApplicationHelper
     number_to_currency(amount, :unit =&gt; '&#8364; ', :separator =&gt; ',', :delimiter =&gt; '.')
   end
   
-  def link_to_destroy title, options={}, html_options={}
-    unless options.is_a?(String)
-      options = {:action =&gt; :delete}.update(options)
-    end
-    html_options = {:confirm =&gt; 'Are you sure?', :method =&gt; :delete}.update(html_options)
-    link_to title, options, html_options
+  def link_to_destroy title, confirm_message, url, fallback_url
+    url = url_for(url) unless url.is_a?(String)
+    fallback_url = url_for(fallback_url) unless fallback_url.is_a?(String)
+    link_to_function title, &quot;confirm_destroy(this, '#{escape_javascript url}', '#{escape_javascript confirm_message}', '#{escape_javascript form_authenticity_token}')&quot;, :href =&gt; fallback_url
   end
 end</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,5 +3,7 @@
   &lt;td&gt;&lt;%= h address.name %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= h address.street %&gt; &lt;%= h address.postcode %&gt; &lt;%= h address.city %&gt; &lt;%= h address.country %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= h address.tax_number %&gt;&lt;/td&gt;
-  &lt;td&gt;&lt;%= link_to 'bearbeiten', edit_address_url(address) %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= link_to 'bearbeiten', edit_address_url(address) %&gt;
+   &lt;%= link_to_destroy 'l&#246;schen', 'Wollen Sie die Adresse wirklich l&#246;schen?', address_path(address), confirm_destroy_address_path(address) %&gt;
+   &lt;/td&gt;
 &lt;/tr&gt;</diff>
      <filename>app/views/addresses/_address.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,11 +2,11 @@
 
 &lt;table id=&quot;addresses&quot;&gt;
   &lt;tr&gt;
-    &lt;th width=&quot;20%&quot;&gt;Firmenname&lt;/th&gt;
+    &lt;th width=&quot;15%&quot;&gt;Firmenname&lt;/th&gt;
     &lt;th width=&quot;20%&quot;&gt;Ansprechperson&lt;/th&gt;
-    &lt;th width=&quot;40%&quot;&gt;Adresse&lt;/th&gt;
+    &lt;th width=&quot;35%&quot;&gt;Adresse&lt;/th&gt;
     &lt;th width=&quot;10%&quot;&gt;Steuernummer&lt;/th&gt;
-    &lt;th width=&quot;10%&quot;&gt;Aktionen&lt;/th&gt;
+    &lt;th width=&quot;20%&quot;&gt;Aktionen&lt;/th&gt;
   &lt;/tr&gt;
   &lt;%= render :partial =&gt; 'address', :collection =&gt; @addresses %&gt;
 &lt;/table&gt;
\ No newline at end of file</diff>
      <filename>app/views/addresses/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -5,5 +5,5 @@
   &lt;td&gt;&lt;%= h address.tax_number %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= link_to 'zeigen', customer_address_path(@customer, address) %&gt;
     &lt;%= link_to 'bearbeiten', edit_customer_address_path(@customer, address) %&gt;
-    &lt;%= link_to_destroy 'l&#246;schen', {:id =&gt; address.id}, {:href =&gt; confirm_destroy_customer_address_path(@customer, address)} %&gt;&lt;/td&gt;
+    &lt;%= link_to_destroy 'l&#246;schen', 'Wollen Sie die Adresse wirklich l&#246;schen?', customer_address_path(@customer, address), confirm_destroy_customer_address_path(@customer, address)} %&gt;&lt;/td&gt;
 &lt;/tr&gt;</diff>
      <filename>app/views/customers/_address.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -3,5 +3,5 @@
   &lt;td&gt;&lt;%= link_to customer.name, customer_url(customer) %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= customer.invoices.count %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= customer.open_invoices.count %&gt;&lt;/td&gt;
-  &lt;td&gt;&lt;%= link_to '&#228;ndern', edit_customer_path(customer) %&gt; &lt;%= link_to 'zeigen', customer_path(customer) %&gt; &lt;%= link_to_destroy 'l&#246;schen', customer_path(customer), {:href =&gt; confirm_destroy_customer_path(customer)} %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= link_to '&#228;ndern', edit_customer_path(customer) %&gt; &lt;%= link_to 'zeigen', customer_path(customer) %&gt; &lt;%= link_to_destroy 'l&#246;schen', 'Wollen Sie den Kunden wirklich l&#246;schen?', customer_path(customer), confirm_destroy_customer_path(customer) %&gt;&lt;/td&gt;
 &lt;/tr&gt;</diff>
      <filename>app/views/customers/_customer.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,6 @@
   &lt;td&gt;&lt;%= number_to_euro(invoice.tax_amount) %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= link_to &quot;&#228;ndern&quot;, edit_invoice_path(invoice) %&gt;
     &lt;%= link_to &quot;zeigen&quot;, customer_invoice_path(@customer, invoice) %&gt; &lt;%= link_to &quot;PDF&quot;, formatted_customer_invoice_path(@customer, invoice, :pdf) %&gt;
-    &lt;%= link_to_destroy &quot;l&#246;schen&quot;, {:id =&gt; invoice.id}, {:href =&gt; confirm_destroy_customer_invoice_path(@customer, invoice)} %&gt; &lt;/td&gt;
+    &lt;%= link_to_destroy &quot;l&#246;schen&quot;, &quot;Wollen Sie diese Rechnung wirklich l&#246;schen?&quot;, customer_invoice_path(@customer, invoice), confirm_destroy_customer_invoice_path(@customer, invoice) %&gt; &lt;/td&gt;
     
 &lt;/tr&gt;
\ No newline at end of file</diff>
      <filename>app/views/customers/_invoice.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -8,6 +8,6 @@
   &lt;td&gt;&lt;%= number_to_euro(invoice.tax_amount) %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= link_to &quot;&#228;ndern&quot;, edit_invoice_path(invoice) %&gt;
     &lt;%= link_to &quot;zeigen&quot;, invoice_path(invoice) %&gt; &lt;%= link_to &quot;PDF&quot;, formatted_invoice_path(invoice, :pdf) %&gt;
-    &lt;%= link_to_destroy &quot;l&#246;schen&quot;, {:id =&gt; invoice.id}, {:href =&gt; confirm_destroy_invoice_path(invoice)} %&gt; &lt;/td&gt;
+    &lt;%= link_to_destroy &quot;l&#246;schen&quot;, 'Wollen Sie die Rechnung wirklich l&#246;schen?', invoice_path(invoice), confirm_destroy_invoice_path(invoice) %&gt; &lt;/td&gt;
     
 &lt;/tr&gt;
\ No newline at end of file</diff>
      <filename>app/views/invoices/_invoice.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 &lt;li&gt;&lt;%= link_to_unless_current 'neue Rechnung', new_invoice_path %&gt;&lt;/li&gt;
 &lt;% unless @invoice.nil? or @invoice.new_record? %&gt;
 &lt;li&gt;&lt;%= link_to_unless_current 'PDF', formatted_invoice_path(@invoice, :pdf) %&gt;&lt;/li&gt;
-&lt;li&gt;&lt;%= link_to_destroy &quot;l&#246;schen&quot;, {:id =&gt; @invoice.id}, {:href =&gt; confirm_destroy_invoice_path(@invoice)} %&gt;&lt;/li&gt;
+&lt;li&gt;&lt;%= link_to_destroy &quot;l&#246;schen&quot;, 'Wollen Sie die Rechnung wirklich l&#246;schen?', invoice_path(@invoice), confirm_destroy_invoice_path(@invoice)  %&gt;&lt;/li&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/invoices/_navigation.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -4,5 +4,5 @@
   &lt;p&gt;
   Wollen Sie die Rechnung wirklich l&#246;schen?
   &lt;/p&gt;
-  &lt;%= submit_tag 'L&#246;schen' %&gt; &lt;%= link_to 'zur&#252;ck zur Rechnung', :back %&gt; 
+  &lt;%= submit_tag 'L&#246;schen' %&gt;
 &lt;/form&gt;</diff>
      <filename>app/views/invoices/confirm_destroy.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,25 @@
 // Place your application-specific JavaScript functions and classes here
 // This file is automatically included by javascript_include_tag :defaults
+/* http://railscasts.com/episodes/77 */
+function confirm_destroy(element, action, confirm_message, auth_token) {
+  if (confirm(confirm_message)) {
+    var f = document.createElement('form');
+    f.style.display = 'none';
+    element.parentNode.appendChild(f);
+    f.method = 'POST';
+    f.action = action;
+    var m = document.createElement('input');
+    m.setAttribute('type', 'hidden');
+    m.setAttribute('name', '_method');
+    m.setAttribute('value', 'delete');
+    f.appendChild(m);
+		var t = document.createElement('input');
+		t.setAttribute('type', 'hidden');
+		t.setAttribute('name', 'authenticity_token');
+		t.setAttribute('value', auth_token);
+		f.appendChild(t);
+		console.log(f);
+    f.submit();
+  }
+  return false;
+}
\ No newline at end of file</diff>
      <filename>public/javascripts/application.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>12afb5355c1b015c5c44137388ffae623a3f55a8</id>
    </parent>
  </parents>
  <author>
    <name>TomK32</name>
    <email>tomk32@tomk32.de</email>
  </author>
  <url>http://github.com/TomK32/exabuch/commit/a23ac106e19d56f8216c1fd0e08059ef9eff023d</url>
  <id>a23ac106e19d56f8216c1fd0e08059ef9eff023d</id>
  <committed-date>2008-05-14T10:37:58-07:00</committed-date>
  <authored-date>2008-05-14T10:37:58-07:00</authored-date>
  <message>deleting objects now with js-fallback, sadly there's a bug in rails (http://dev.rubyonrails.org/ticket/11097) but with a custom js-method is more elegant anyways</message>
  <tree>60282d3e697827d764699d3aea722bbf5f477209</tree>
  <committer>
    <name>TomK32</name>
    <email>tomk32@tomk32.de</email>
  </committer>
</commit>
