Guest User

Untitled

a guest
Apr 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. # model.rb
  2.  
  3. def starts_at_day=(day)
  4. self.starts_at = self.starts_at.sub(/\d\d$/, day)
  5. end
  6.  
  7. # test
  8.  
  9. def test_starts_at_day_is_writeable
  10. s = Story.create :name => "foobar", :starts_at => "1111", :ends_at => "0909"
  11. # Is date the only part that is changed?
  12. s.starts_at_day = "22"
  13. assert s.save
  14. assert_equal "1122", s.starts_at
  15. end
  16.  
  17. # error when trying through webinterface
  18.  
  19. You have a nil object when you didn't expect it!
  20. The error occurred while evaluating nil.sub
Add Comment
Please, Sign In to add comment