main
1class User < ActiveRecord::Base
2 devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
3 after_save :get_location
4
5 attr_accessible :name, :email, :password, :password_confirmation, :remember_me, :postal_code, :latitude, :longitude
6 has_many :needs
7 has_many :links
8 acts_as_tagger
9
10private
11
12 def get_location
13
14 return if self.postal_code.nil?
15
16 location = GeoLocationService.GetGeoLocation(self.postal_code)
17
18 return if location.nil?
19
20 update_column :latitude, location.y
21 update_column :longitude, location.x
22
23 end
24
25end