
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 1.16 KB | hits: 8 | expires: Never
ROR Error message
@supplier_store_array = PurchaseIndentDetail.find(:all,:conditions =>
"pid.recommended_for = 'PO' and pid.purchase_order_detail_id is null and
pi.approved_status='Approved' and (pi.amendment_status = 'Approved' or
pi.amendment_status is null or pi.amendment_status = 'None') and i.is_asset = '0'",
:joins => "as pid inner join purchase_indents as pi on
pi.id=pid.purchase_indent_id inner join items as i on pid.item_id=i.id",
:select => "pid.*").inject([]){|acc,pid|
ih = pid.item.item_subtype.item_type.item_group.store_category.inventory_heads
.find(:first, :conditions => ["location_id = ?",
Location.find(:first, :conditions => ["is_central = true"]).id])
item_inventory_head_id = ih ? ih.id : pid.item.item_subtype.item_type.item_group
.store_category.inventory_heads[0].id
acc.include?([pid.supplier_id, item_inventory_head_id]) ?
acc : acc << [pid.supplier_id, item_inventory_head_id]
}
if ih.nil?
raise 'some error'
end
class MyException < Exception
end
if ih.nil?
raise MyException.new
end
rescue_from MyException do
render :template => 'my_exception_happened'
end