aboutsummaryrefslogtreecommitdiff
path: root/app/models/resource.rb
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-09 12:47:31 +0200
committerhellekin <hellekin@cepheide.org>2020-10-09 12:47:31 +0200
commitdd9e0691acae3eb63bdfbc8665eb3f8ce516536d (patch)
tree41d5889f2a0882b4f4356ed60683e908abf0b208 /app/models/resource.rb
parentfd9e9c4679ea36bed60acf01a43dda307db203e4 (diff)
downloadincommon-map-dd9e0691acae3eb63bdfbc8665eb3f8ce516536d.tar.gz
Fix Resource edition
Diffstat (limited to 'app/models/resource.rb')
-rw-r--r--app/models/resource.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/app/models/resource.rb b/app/models/resource.rb
index 906933d..7d87e1a 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -8,8 +8,7 @@ class Resource < ApplicationRecord
has_many :classifications
has_many :sections, through: :classifications
- serialize :feature, HashSerializer
- store_accessor :feature, :name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website
+ store_accessor :feature, :geometry, :properties
validates_associated :agent
@@ -53,4 +52,16 @@ class Resource < ApplicationRecord
def latitude=(value)
feature['geometry']['coordinates'][1] = value
end
+
+ # Properties
+
+ [:name, :summary, :description, :email, :source, :address, :postal_code, :city, :phone_number, :website].each do |prop|
+ # Define a reader
+ define_method prop do
+ properties[prop.to_s]
+ end
+ define_method :"#{prop}=" do |v|
+ feature['properties'][prop.to_s] = v
+ end
+ end
end