Join GitHub today
Use #presence when fetching field's value. #1387
I encountered an exception when trying to display IPAddr field in show view. That happens because of IPAddr#<=> implementation (see http://www.ruby-doc.org/stdlib-1.9.3/libdoc/ipaddr/rdoc/IPAddr.html#method-i-3C-3D-3E).
irb(main):006:0> ip = IPAddr.new('127.0.0.1') => #<IPAddr: IPv4:127.0.0.1/255.255.255.255> irb(main):007:0> ip !=  NoMethodError: undefined method `to_i' for :Array irb(main):008:0> ip != '' ArgumentError: invalid address
I suspect there may be other classes (custom or in stdlib) that may be affected by this. ActiveSupport's #presence, based on #blank? seems to yield the expected result.