Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 10, 2012

Conversation

saulius
Copy link
Contributor

@saulius 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
Copy link
Collaborator

sferik commented Nov 10, 2012

Thanks for the patch!

sferik added a commit that referenced this pull request Nov 10, 2012
Use #presence when fetching field's value.
@sferik sferik merged commit 92f7d80 into railsadminteam:master Nov 10, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants