mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Update customers_controller.rb
This commit is contained in:
@@ -20,7 +20,7 @@ class CustomersController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
if params[:search]
|
if params[:search]
|
||||||
@customers = Customer.search(params[:search]).paginate(:page => params[:page])
|
@customers = Customer.search(params[:search]).paginate(:page => params[:page])
|
||||||
if @customers.count = 1
|
if only_one_non_zero?(@customers)
|
||||||
redirect_to @customers.first
|
redirect_to @customers.first
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -89,4 +89,17 @@ class CustomersController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def only_one_non_zero?( array )
|
||||||
|
found_non_zero = false
|
||||||
|
array.each do |val|
|
||||||
|
if val!=0
|
||||||
|
return false if found_non_zero
|
||||||
|
found_non_zero = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
found_non_zero
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user