How to display your website visitor's ip address in Rails way

1. Do as follows in app/controllers/application_controller.rb:

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception

  def remote_ip
      request.remote_ip
  end
end

Comments