私はちょうど私のアプリにジオコーダーの宝石を含んでいました。すべてが完璧に動作しますが、私は宝石をさらに利用できるかどうか疑問に思っていました。Geocoder Gem - Ruby On Rails
私のアプリケーションにはユーザーがいて、記事を追加することはできます。
@article.ip_address = request.remote_ip
を使用して私ができる自分のIPアドレス現時点では私は私が国の名にそのIPアドレスを変換することができますが、私は何かを見つけることができません宝石を探しています。私はジオコーダを使用しているので、彼らのウェブサイトで私のIP、都市、国を自動的に検出することがわかります。私はこれを私のコントローラーにどのように実装できるのだろうかと思っていた。
def create
@article = Breeder.new(params[:breeder])
@article.user = current_user
@article.ip_address = request.remote_ip
respond_to do |format|
if @article.save
format.html { redirect_to @article, notice: 'Article was successfully created.' }
format.json { render json: @article, status: :created, location: @article }
else
format.html { render action: "new" }
format.json { render json: @article.errors, status: :unprocessable_entity }
end
end
エンド
アイデアは、英国からでない記事を検出することです。
https://github.com/alexreisner/geocoder
ありがとう、ありがとう。 omhhhh私はどのように上記のコードに実装するのですか?もう一度ありがとう、本当に一目惚れです。 – Benjamin