Geocoding only occurs avec address has changed

rails5
echarp 6 years ago
parent f1a286d8cc
commit 4f8cf33f90
  1. 5
      app/models/event.rb
  2. 6
      db/schema.rb

@ -27,8 +27,9 @@ class Event < ActiveRecord::Base
validates :submitter, email: true
geocoded_by :full_address
# after_validation :geocode, if: -> (obj) { obj.address_changed? }
after_validation :geocode
after_validation :geocode, if: (lambda do |obj|
obj.address_changed? || obj.city_changed?
end)
# Mechanism to store some reason which can be used when sending notifications
attr_accessor :reason

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161210105333) do
ActiveRecord::Schema.define(version: 20161210154558) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace", limit: 255
@ -70,7 +70,7 @@ ActiveRecord::Schema.define(version: 20161210105333) do
t.string "contact", limit: 255, default: "", null: false
t.string "submitter", limit: 255, default: "", null: false
t.integer "moderated", limit: 4, default: 0, null: false
t.text "tags", limit: 255, default: "", null: false
t.text "tags", limit: 255, default: ""
t.string "secret", limit: 255, default: "", null: false
t.datetime "decision_time"
t.datetime "submission_time"
@ -124,7 +124,7 @@ ActiveRecord::Schema.define(version: 20161210105333) do
t.datetime "created_at"
t.datetime "updated_at"
t.text "tag"
t.text "tags", default: "", null: false
t.text "tags", default: ""
t.text "diaspora"
t.text "object_changes"
t.text "place_name"

Loading…
Cancel
Save