Created
July 30, 2019 01:32
-
-
Save jordanhudgens/dcaff73c63cb08378e12cb38f45a35b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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