Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. ## Load a person, show that needs_loan == false
  2. >> person = Person.find(18)
  3. # ... snip ...
  4. >> person.needs_loan
  5. => false
  6.  
  7. ## Show that I can set needs_loan by hand and save
  8. >> person.needs_loan = true
  9. => true
  10. >> person.save!
  11. => true
  12. >> person.needs_loan
  13. => true
  14.  
  15. ## set it to false again
  16. >> person.needs_loan = false
  17. => false
  18. >> person.save!
  19. => true
  20.  
  21. ## show that they are associated with an active loan
  22. >> person.loan_requests.size
  23. => 4
  24. >> person.loan_requests.any? { |l| l.active? }
  25. => true
  26.  
  27. ## run the update_needs_loan! method to try to have the model set its
  28. # own attribute to true
  29. >> person.update_needs_loan!
  30. => true
  31. >> person.needs_loan
  32. => false # It doesn't work. What gives?
Add Comment
Please, Sign In to add comment