Ruby on Rails Monday, August 29, 2011

Christoph B. wrote in post #1019055:
> Hey, I have the following line in my controller:
>
> User.create(:email => "fuuu@bar.com", :password =>
> 'asldfkjadsfadsf', :ip => request.remote_ip)
>
> now User.find_by_ip('127.0.0.1') returns 0
> records
>
> if I change it to:
>
> User.create(:email => "fuuu@bar.com", :password =>
> 'asldfkjadsfadsf', :ip => '127.0.0.1')
> the finder returns the record
>

That seems like definitive proof that:

request.remote_ip != '127.0.01'

In fact you could test that:

if request.remote_ip == '127.0.0.1
puts 'yes'
else
puts 'no'
end


> inspect returns:
>
> ruby-1.9.2-p180 :009 > DocType.all.map {|d| d.name.inspect}
> DocType Load (1.4ms) SELECT "doc_types".* FROM "doc_types"
> => ["\"127.0.0.1\"", "\"127.0.0.1\""]
>

The output shows that the string is actually "127.0.0.1"--not 127.0.0.1.
For example:

data = [
%q{"127.0.0.1"},
%q{127.0.0.1}
]

data.each do |str|
p str
end

--output:--
"\"127.0.0.1\""
"127.0.0.1"

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment