httpリクエストからIPアドレスを取得するジオコーダ宝石を使用しています。ドキュメントから:Ruby:オブジェクトを読み取り可能なものに変更する方法
Geocoder adds a +location+ method to the standard <tt>Rack::Request</tt> object so you can easily look up the location of any HTTP request by IP address. For example, in a Rails controller or a Sinatra app:
# returns Geocoder::Result object
result = request.location
私は私のコントローラで
@result = request.location
を配置し、私の見解で
<%= @result %>
しかし、私はこれを得ました。
#<Geocoder::Result::Freegeoip:0x00000102dc7758>
私はその後
<%= @result.to_s %>
を試してみましたが、それは何も変更しませんでした。
アイデア?
[ 'request.location'の戻り値](http://rubydoc.info/gems/geocoder/Geocoder/Result/:
ここではそのソースですFreegeoip)にはさまざまな方法がありますが、それらを使って試すことができます。 –
ありがとうございますが、ip_addressがそれらのメソッドの1つではないというのは奇妙なことではありませんか?アドレスメソッドは物理アドレスのようです。 – Leahcim
'request.ip'、少なくともそれは彼らが言うことですhttp://www.rubygeocoder.com/ –