summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 4a170b9..a471980 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,8 +1,25 @@
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
+ after_save :get_location
- attr_accessible :name, :email, :password, :password_confirmation, :remember_me
+ attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :postal_code, :latitude, :longitude
has_many :needs
has_many :links
acts_as_tagger
+
+private
+
+ def get_location
+
+ return if self.postal_code.nil?
+
+ location = GeoLocationService.GetGeoLocation(self.postal_code)
+
+ return if location.nil?
+
+ update_column :latitude, location.y
+ update_column :longitude, location.x
+
+ end
+
end