Quoting sol <[email protected]>:
> This is really weird, either a bug (it's 3.1 rc5) or I don't know:
> 
> 1) DocType.create(:name => request.remote_ip)
>   DocType.find_by_name('127.0.0.1')
>   DocType Load (1.4ms)  SELECT "doc_types".* FROM "doc_types" WHERE
> "doc_types"."name" = '127.0.0.1' LIMIT 1
>  => nil
> 

Dynamic typing is wonderful, until it isn't.  My hypothesis is that remote_ip
is not a Fixnum or Bignum but a custom class that overrides to_s.  To test the
hypothesis, I'd run the following in the console of writing to the log.

puts request.remote_ip.class
puts request.remote_ip
puts request.remote_ip.to_s
puts "#{request.remote_ip}"
puts request.remote_ip.inspect

DocType.create(:name => request.remote_ip)
DocType.last
DocType.create(:name => request.remote_ip.to_s)
DocType.last

Somewhere in this, I expect the truth will be revealed.

A IPv4 address is a 32 bit, unsigned number.  It is usually
represented/rendered in dotted quad notation, but 0x7F000001 or 2130706433 are
equally valid representations of the local or loopback interface's IPv4
address.

HTH,
  Jeffrey

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to