Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # model.rb
- def starts_at_day=(day)
- self.starts_at = self.starts_at.sub(/\d\d$/, day)
- end
- # test
- def test_starts_at_day_is_writeable
- s = Story.create :name => "foobar", :starts_at => "1111", :ends_at => "0909"
- # Is date the only part that is changed?
- s.starts_at_day = "22"
- assert s.save
- assert_equal "1122", s.starts_at
- end
- # error when trying through webinterface
- You have a nil object when you didn't expect it!
- The error occurred while evaluating nil.sub
Add Comment
Please, Sign In to add comment