Skip to content

Instantly share code, notes, and snippets.

@jordanhudgens
Created July 30, 2019 01:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanhudgens/dcaff73c63cb08378e12cb38f45a35b3 to your computer and use it in GitHub Desktop.
Save jordanhudgens/dcaff73c63cb08378e12cb38f45a35b3 to your computer and use it in GitHub Desktop.
# app/models/user.rb
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
belongs_to :plan
has_one :profile
geocoded_by :ip_lookup, :latitude => :lat, :longitude => :long
before_save :geocode
private
def ip_lookup
ip = Thread.current[:request].remote_ip
if ip == '127.0.0.1' || ip == '::1'
'70.184.119.26'
else
ip
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment