Use #presence when fetching field's value. #1387

Merged
merged 1 commit into from Nov 10, 2012

Conversation

Projects
None yet
2 participants
@saulius
Contributor

saulius commented Nov 10, 2012

Hi,

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.

@sferik

This comment has been minimized.

Show comment
Hide comment
@sferik

sferik Nov 10, 2012

Owner

Thanks for the patch!

Owner

sferik commented Nov 10, 2012

Thanks for the patch!

sferik added a commit that referenced this pull request Nov 10, 2012

Merge pull request #1387 from sauliusg/patch1
Use #presence when fetching field's value.

@sferik sferik merged commit 92f7d80 into sferik:master Nov 10, 2012

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment