You do not need to add before_filter to geocode_ip_address, but just add this to your controller:
class YourController < ApplicationController geocode_ip_address def action if geo = session[:geo_location]
Please note that if geo coding failure geo will be zero. If you are working in development, you will try to geocode 127.0.0.1, so you need to set your remote_ip to the request object. I did this by adding this to the end of config / environment / development.rb :
class ActionDispatch::Request def remote_ip "xxxx" # fill in your IP address here end end
source share