Created
June 26, 2012 08:53
-
-
Save joakimk/2994514 to your computer and use it in GitHub Desktop.
Virtus: empty string on Integer is empty string. By design or bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'virtus' | |
class Record | |
include Virtus | |
attribute :count, Integer | |
end | |
record = Record.new | |
record.count = '' | |
puts "Expecting nil:" | |
p record.count # -> '' | |
# This is problematic with form input that is either an empty string | |
# or an integer (a database id). Besides, '' isn't an integer. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment