Skip to content

Instantly share code, notes, and snippets.

@joakimk
Created June 26, 2012 08:53
Show Gist options
  • Save joakimk/2994514 to your computer and use it in GitHub Desktop.
Save joakimk/2994514 to your computer and use it in GitHub Desktop.
Virtus: empty string on Integer is empty string. By design or bug?
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