daily pastebin goal
42%
SHARE
TWEET

Untitled

a guest May 17th, 2018 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### mod to basket_controller.rb
  2.  
  3.   def basket_takes(id)
  4.     if id == "all"
  5.       session[:basket]['Space'].each {|k,v|
  6.         apple = Inventory.find(k, :conditions => ["billable_type = ?",'Space'])
  7.         apple.update_attribute(:stock_qty, apple.stock_qty + 1)
  8.       }
  9.       session[:basket].clear
  10.     else
  11.       apple = Inventory.find(id)
  12.       apple.update_attribute(:stock_qty, apple.stock_qty + 1)
  13.       session[:basket][apple.variety][apple.id] -= 1
  14.       session[:basket][apple.variety].delete_if {|k,v| v == 0}
  15.       session[:basket].delete_if {|k,v| v.empty?} #<^ i think this is a bit of a wtf.
  16.     end
  17.   end
  18.  
  19. ### mod to apple.rb
  20.  
  21.   def initialize(id,basket)
  22.     @apple = id.to_i
  23.     inv = Inventory.find(@apple)
  24.     @variety = inv.billable_type
  25.     inv.update_attribute(:stock_qty,inv.stock_qty - 1)
  26.     if basket[@variety] && basket[@variety].has_key?(@apple)
  27.       @quantity = basket[@variety][@apple] + 1
  28.     else
  29.       @quantity = 1
  30.     end
  31.   end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top