Guest User

Mentee Addition script

a guest
Apr 14th, 2019
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. mentee_emails = ["manaranjanfav@gmail.com","mridul.sharma@iitgn.ac.in","nitingovilkar97@gmail.com","princeraj.14oct@gmail.com"]
  3.  
  4. new_mentee = []
  5.  
  6. mentee_emails.each{|mentee_email|
  7. u = User.find_by(:email => mentee_email)
  8. if u.present?
  9. next if Mentee.find_by(user_id: u.id).present?
  10. mentee = Mentee.new(:user_id => u.id)
  11. mentee.save!
  12. MenteeBatch.create(:batch_id => 1, :mentee_id => mentee.id)
  13. new_mentee << mentee
  14. end
  15. }
  16.  
  17. # Double check content before sending mails
  18. new_mentee_user_id = Mentee.where("id > 327").pluck(:user_id)
  19. new_mentee_user_id.each{|user_id|
  20. NoLayoutMailer.send_adhoc_mailer(user_id, {subject: 'Select Your Mentor | InterviewBit Academy'}).deliver_now
  21. }
Add Comment
Please, Sign In to add comment