summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-06-23 23:10:05 -0600
committermo khan <mo@mokhan.ca>2013-06-23 23:10:05 -0600
commitd50c5834cf7ae1cbb22423f2a214956c97bbeaea (patch)
treed03256695bebc37a689c1fc57df768c0f8adce33 /app/models/user.rb
parenta2b743102f1aa00541cff0da596c584574faf9e8 (diff)
parente3835d71e4bb3a530b06e4f459ea9643adbe9f6c (diff)
merge with mendicantmain
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