added geocoding
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
class Supporter
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Geocoder::Model::Mongoid
|
||||
|
||||
geocoded_by :address
|
||||
after_validation :geocode # auto-fetch coordinates
|
||||
|
||||
field :first_name, type: String
|
||||
field :last_name, type: String
|
||||
@@ -10,6 +14,7 @@ class Supporter
|
||||
field :email, type: String
|
||||
field :support, type: String # Indicates the type of support
|
||||
field :age_category, type: String
|
||||
field :coordinates, type: Array
|
||||
|
||||
validates :first_name, presence: true
|
||||
validates :last_name, presence: true
|
||||
@@ -19,4 +24,8 @@ class Supporter
|
||||
validates :email, presence: true, uniqueness: true
|
||||
validates :support, presence: true
|
||||
validates :age_category, presence: true
|
||||
|
||||
def address
|
||||
"#{street}, #{zip}, #{city}, Switzerland"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user