give proper block to link_to_ordering (closes #201)

This commit is contained in:
wvengen 2013-12-11 22:58:45 +01:00
parent e25570d870
commit b53cb36714
2 changed files with 9 additions and 9 deletions

View file

@ -9,17 +9,17 @@ module GroupOrdersHelper
# Returns a link to the page where a group_order can be edited. # Returns a link to the page where a group_order can be edited.
# If the option :show is true, the link is for showing the group_order. # If the option :show is true, the link is for showing the group_order.
def link_to_ordering(order, options = {}) def link_to_ordering(order, options = {}, &block)
group_order = order.group_order(current_user.ordergroup) group_order = order.group_order(current_user.ordergroup)
path = if options[:show] and group_order path = if options[:show] and group_order
group_order_path(group_order) group_order_path(group_order)
elsif group_order elsif group_order
edit_group_order_path(group_order, :order_id => order.id) edit_group_order_path(group_order, :order_id => order.id)
else else
new_group_order_path(:order_id => order.id) new_group_order_path(:order_id => order.id)
end end
options.delete(:show) options.delete(:show)
name = block_given? ? yield(order, group_order) : order.name name = block_given? ? capture(&block) : order.name
path ? link_to(name, path, options) : name path ? link_to(name, path, options) : name
end end

View file

@ -22,7 +22,7 @@
%td= "#{show_user group_order.updated_by} (#{format_time(group_order.updated_on)})" %td= "#{show_user group_order.updated_by} (#{format_time(group_order.updated_on)})"
%td.numeric %td.numeric
= link_to_ordering(order, show: true) do = link_to_ordering(order, show: true) do
- number_to_currency(group_order.price) = number_to_currency(group_order.price)
- else - else
%td{:colspan => 2} %td{:colspan => 2}
- if total > 0 - if total > 0