Guest User

Untitled

a guest
Jun 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. def make_temp_storage
  2. pr = Product.find( product_id ) rescue nil
  3. return nil unless pr
  4. size = ProductSize.find( product_size_id ) rescue pr.product_sizes.first
  5. color = ProductColor.find( product_color_id ) rescue pr.product_colors.first
  6. quantity = ProductQuantity.find( product_quantity_id ) rescue pr.product_quantities.first
  7. price = ProductPrice.find( :first, :conditions =>
  8. [ "product_size_id = ? AND product_color_id = ? AND product_quantity_id = ?",
  9. size.id, color.id, quantity.id ] )
  10. return nil if price.nil?
  11.  
  12. # WTF is Exception???
  13. # Rescue it all!
  14. # :D
Add Comment
Please, Sign In to add comment