Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.16 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ROR Error message
  2. @supplier_store_array = PurchaseIndentDetail.find(:all,:conditions =>
  3.  "pid.recommended_for = 'PO' and pid.purchase_order_detail_id is null and
  4.  pi.approved_status='Approved' and (pi.amendment_status = 'Approved' or
  5.  pi.amendment_status is null or pi.amendment_status = 'None') and i.is_asset = '0'",
  6.  :joins => "as pid inner join purchase_indents as pi on
  7.  pi.id=pid.purchase_indent_id inner join items as i on pid.item_id=i.id",
  8.  :select => "pid.*").inject([]){|acc,pid|
  9.  
  10.  ih = pid.item.item_subtype.item_type.item_group.store_category.inventory_heads
  11.      .find(:first, :conditions => ["location_id = ?",
  12.      Location.find(:first, :conditions => ["is_central = true"]).id])
  13.  
  14.  item_inventory_head_id = ih ? ih.id : pid.item.item_subtype.item_type.item_group
  15.                                       .store_category.inventory_heads[0].id
  16.  
  17.  
  18.  acc.include?([pid.supplier_id, item_inventory_head_id]) ?
  19.  acc : acc << [pid.supplier_id, item_inventory_head_id]
  20. }
  21.        
  22. if ih.nil?
  23.   raise 'some error'
  24. end
  25.        
  26. class MyException < Exception
  27. end
  28.        
  29. if ih.nil?
  30.   raise MyException.new
  31. end
  32.        
  33. rescue_from MyException do
  34.   render :template => 'my_exception_happened'
  35. end