So finally got Geocoder to work with this code:
geocoded_by :ip_address before_validation :geocode
Only problem is that "ip_address" field. I've tried to get the ip_address 90,000 different ways and NONE of them work.
I was finally able to capture the ip_address in the user.edit form by doing:
<%= f.text_field :ip_address, :value => request.remote_ip %></div>
Now of course the problem is I want the ip address to automatically be saved in the user field whenever the user logs in or whenever a new user is created. to that end I have tried EVERYTHING and nothing has worked. I've tried:
def ip_address ip_address = request.remote_ip end
def ip_address @user.ip_address = request.remote_ip end def edit
def edit @user = User.find(params[:id]) ip_address = request.remote_ip end
def update @user = User.find(params[:id]) ip_address = request.remote_ip if @user.update_attributes(params[:user]) redirect_to @user else render :edit end end
NOTHING seems to save the request.remote_ip into the :ip_address field besides doing it in a form.
Ultimately what I want to do is get Geocoder to save the country in the :country field.