NoMethodError: undefined method `loopback?' for 127.0.0.1:IPAddress::IPv4 #25

Open
xanview opened this Issue Sep 13, 2012 · 4 comments

Projects

None yet

6 participants

@xanview
xanview commented Sep 13, 2012

I'm trying to check if my IP is a loopback ip, I get this:

ip = IPAddress('127.0.0.1').loopback?
NoMethodError: undefined method `loopback?' for 127.0.0.1:IPAddress::IPv4
    from (irb):9
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Any ideas?

@aderouineau

It is not implemented. The IPv6 equivalent doesn't seem completely valid either :

IPAddress(IPAddress("127.0.0.1").to_ipv6).loopback?
=> false

IPAddress("::ffff:127.0.0.1").loopback?
=> false
@mikemackintosh mikemackintosh self-assigned this Mar 26, 2015
@tisba
tisba commented Jan 4, 2016

My current workaround is to check if a given IP address is included in 127.0.0.0/8 (I only need v4 currently). Would be a nice addition to the gem's feature set!

@francisluong
Member

It'd be easy enough to include this in a PR but when is 1.0 coming out. I would imagine most are hesitant to contribute changes that would get clobbered by a major release.

@bluemonk
Collaborator
bluemonk commented Jan 5, 2016

This was fixed by Mike in f562a7f7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment