Guest User

Untitled

a guest
Mar 18th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. # Add referrals only to new users
  2. referred_by = params[:referred_by]
  3. if referred_by.present?
  4. if User.exists?(referred_by)
  5. referrer = User.find(referred_by)
  6. subscription = PaymentSystem.get_subscription(referrer.subscription_id)
  7. if subscription.trial_end > Time.now.to_i
  8. subscription.trial_end = (Time.at(subscription.trial_end) + 90.days).to_i
  9. else
  10. subscription.trial_end = (Time.now + 90.days).to_i
  11. end
  12. subscription.save
  13. @user.referred_by = referred_by.to_i
  14. end
  15. end
Add Comment
Please, Sign In to add comment