From 218b3e45a4890d3c37dde148dbe2a88cda89df01 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 29 Nov 2011 11:46:41 +0100 Subject: [PATCH] Fixed crash in CustomersNTasksNew#get The @customer_list was not set (closes: #ae0311). Also made Views#_form_select more robust by also catching undefined lists and treating them as empty lists. --- stoptime.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stoptime.rb b/stoptime.rb index aa22496..f85b952 100644 --- a/stoptime.rb +++ b/stoptime.rb @@ -635,6 +635,9 @@ module StopTime::Controllers # for a customer with the given _customer_id_ using Views#task_form. def get(customer_id) @customer = Customer.find(customer_id) + @customer_list = Customer.all.map do |c| + [c.id, c.short_name.present? ? c.short_name : c.name] + end @task = Task.new(:hourly_rate => @customer.hourly_rate) @input = @task.attributes @input["type"] = @task.type # FIXME: find nicer way! @@ -1727,7 +1730,7 @@ module StopTime::Views # The option list is an Array of a 2-valued array containg a value label # and a human readable description for the value. def _form_select(name, opts_list) - if opts_list.empty? + if opts_list.blank? select :name => name, :id => name, :disabled => true do option "None found", :value => "none", :selected => true end