Commit 166c0dda
Changed files (3)
app
models
app/models/user.rb
@@ -2,7 +2,12 @@ class User < ActiveRecord::Base
include PublicActivity::Model
tracked
geocoded_by :current_sign_in_ip, :latitude => :latitude, :longitude => :longitude
- reverse_geocoded_by :latitude, :longitude, :address => :city
+ reverse_geocoded_by :latitude, :longitude do |obj,results|
+ if geo = results.first
+ obj.full_address = geo.formatted_address
+ end
+ end
+
after_validation :geocode, :reverse_geocode
validates :name, :presence => true
validates :website, :format => URI::regexp(%w(http https)), :allow_blank => true
db/migrate/20130702213105_add_full_address_to_users.rb
@@ -0,0 +1,5 @@
+class AddFullAddressToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :full_address, :string
+ end
+end
db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130702005130) do
+ActiveRecord::Schema.define(:version => 20130702213105) do
create_table "active_admin_comments", :force => true do |t|
t.integer "resource_id", :null => false
@@ -228,6 +228,7 @@ ActiveRecord::Schema.define(:version => 20130702005130) do
t.datetime "locked_at"
t.string "authentication_token"
t.string "invitation_token"
+ t.string "full_address"
end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true