added counter

This commit is contained in:
2015-10-19 08:25:26 +02:00
parent bffa85f28e
commit 2f45cbd558
5 changed files with 41 additions and 0 deletions
+7
View File
@@ -3,6 +3,8 @@ class Supporter
include Mongoid::Timestamps
include Geocoder::Model::Mongoid
COUNTER_START = 1331
geocoded_by :address
after_validation :geocode # auto-fetch coordinates
@@ -25,6 +27,11 @@ class Supporter
validates :support, presence: true
validates :age_category, presence: true
def self.counter
actual = count.to_i
actual > COUNTER_START ? actual : COUNTER_START
end
def address
"#{street}, #{zip}, #{city}, Switzerland"
end