From 017275f40ea2d13bab8f4899d8455061561a8f76 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 12 Jun 2013 15:40:36 +1000 Subject: [PATCH] fix error when order has no payments (ie not yet complete) --- app/overrides/add_capture_order_shortcut.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index 005fe34d14..b27dd95783 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -2,8 +2,10 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", #copied from backend / app / views / spree / admin / payments / _list.html.erb: - :text => '<% order.payments.last.actions.grep(/^capture$/).each do |action| %> - <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + :text => '<% if ! order.payments.empty? %> + <% order.payments.last.actions.grep(/^capture$/).each do |action| %> + <%= link_to_with_icon "icon-#{action}", t(action), fire_admin_order_payment_path(order, order.payments.last, :e => action), :method => :put, :no_text => true, :data => {:action => action} %> + <% end %> <% end %>' )