aboutsummaryrefslogtreecommitdiff
path: root/app/models/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/resource.rb')
-rw-r--r--app/models/resource.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/models/resource.rb b/app/models/resource.rb
index c603978..b803afb 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -21,7 +21,7 @@ class Resource < ApplicationRecord
length: { in: 3..64 }
validates :email,
- with: { format: URI::MailTo::EMAIL_REGEXP },
+ format: { with: URI::MailTo::EMAIL_REGEXP },
allow_blank: true
validates :source,
@@ -31,7 +31,8 @@ class Resource < ApplicationRecord
phony_normalize :phone_number, default_country_code: 'BE', normalize_when_valid: true
validates :phone_number,
- phony_plausible: { ignore_record_country_code: true, ignore_record_country_number: true }
+ phony_plausible: { ignore_record_country_code: true, ignore_record_country_number: true },
+ allow_blank: true
# Depends on validate_url Gem
validates :website,
@@ -47,19 +48,19 @@ class Resource < ApplicationRecord
format('%<lon>3.7f', lon: feature['geometry']['coordinates'][0]).to_f
end
def longitude=(value)
- feature['geometry']['coordinates'][0] = format('%<lon>3.7f', lon: value).to_f
+ feature['geometry']['coordinates'][0] = format('%<lon>3.7f', lon: value.to_f).to_f
end
# You can use, e.g.: res.latitude = 0.123
def latitude
format('%<lat>2.7f', lat: feature['geometry']['coordinates'][1]).to_f
end
def latitude=(value)
- feature['geometry']['coordinates'][1] = format('%<lat>2.7f', lat: value).to_f
+ feature['geometry']['coordinates'][1] = format('%<lat>2.7f', lat: value.to_f).to_f
end
# Properties
- [:name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website].each do |prop|
+ [:name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website, :entry_number].each do |prop|
# Define a reader
define_method prop do
properties[prop.to_s]