Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Load a person, show that needs_loan == false
- >> person = Person.find(18)
- # ... snip ...
- >> person.needs_loan
- => false
- ## Show that I can set needs_loan by hand and save
- >> person.needs_loan = true
- => true
- >> person.save!
- => true
- >> person.needs_loan
- => true
- ## set it to false again
- >> person.needs_loan = false
- => false
- >> person.save!
- => true
- ## show that they are associated with an active loan
- >> person.loan_requests.size
- => 4
- >> person.loan_requests.any? { |l| l.active? }
- => true
- ## run the update_needs_loan! method to try to have the model set its
- # own attribute to true
- >> person.update_needs_loan!
- => true
- >> person.needs_loan
- => false # It doesn't work. What gives?
Add Comment
Please, Sign In to add comment