daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def index
  2.     @customer = Customer.find(params[:customer_id])
  3.  
  4.     @unused_count = @customer.purchases.outstanding.count
  5.     @expired_count = @customer.purchases.expired.count
  6.     @used_count = @customer.purchases.redeemed.count
  7.     @total_count = @customer.deals.count
  8.  
  9.     # initialize with 'all'
  10.     purchases = @customer.purchases
  11.  
  12.     # then drill down further into scopes if necessary
  13.     if params[:filter] == "active"
  14.       purchases = purchases.outstanding
  15.     elsif params[:filter] == "used"
  16.       purchases = purchases.redeemed
  17.     elsif params[:filter] == "expired"
  18.       purchases = purchases.expired
  19.     else
  20.       # default is to show active deals
  21.       purchases = purchases.outstanding
  22.     end
  23.  
  24.     if params[:sort] == 'expiration'
  25.         purchases = purchases.order(:expiration_date)
  26.     elsif params[:sort] == 'purchase'
  27.         purchases = purchases.order(:purchased_on)
  28.     end
  29.  
  30.     @purchases = purchases.search(params[:q]).page(params[:page])
  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