seperate rails logic for parameters for showing products

This commit is contained in:
2012-09-17 16:04:04 +02:00
parent c573c83c4c
commit 29848bb3cf
3 changed files with 28 additions and 9 deletions
+6 -1
View File
@@ -127,7 +127,12 @@ class UserController < ApplicationController
products = @table.supplier.products
products.include_relation(:product_categories)
products.sort_by!{|p| p.product_category.try(:position) || 90000}
h = products.inject({table_number: @table.number, supplier_name: @table.supplier.name}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
h = products.inject({
table_number: @table.number,
supplier_name: @table.supplier.name,
has_occupied_info: true,
is_occupied: @table.occupied?
}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h}
render json: h
end
end