This project is archived and is in readonly mode.
model.errors.empty? broken
-
Ryan Bigg
I can only duplicate this by having an invalid object first and then checking the errors:
irb(main):002:0> board = Board.new
=> # irb(main):003:0> board.save
=> false irb(main):004:0> board.errors.empty?
=> false irb(main):005:0> board.errors
=> {:title=>["can't be blank"]} irb(main):006:0> board.title = "Some title"
=> "Some title" irb(main):007:0> board.errors.empty?
=> false irb(main):008:0> board.save
=> true irb(main):009:0> board.errors.empty?
=> trueOther than that, this is behaving as expected.
-
Ryan Bigg
Bah, sorry, I made up what your example was doing and I just tried the real-world one. I see now.
-
Ryan Bigg
Here, have a patch.
-
Repository
- State changed from new to resolved
(from [d748cc3cd07c6931e5ebc5242f268f1f7ec3d906]) Re-define empty? for errors to check if the values inside the OrderedHash are empty rather than the OrderedHash itself. [#4356 model.errors.empty? broken state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/d748cc3cd07c6931e5ebc5242f268f...
