aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/public_body.rb')
-rw-r--r--app/models/public_body.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 9b2a20d82..d11ed683a 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -68,7 +68,7 @@ class PublicBody < ActiveRecord::Base
validate :request_email_if_requestable
- before_save :set_api_key
+ before_save :set_api_key!, :unless => :api_key
before_save :set_default_publication_scheme
after_save :purge_in_cache
after_update :reindex_requested_from
@@ -187,7 +187,11 @@ class PublicBody < ActiveRecord::Base
end
def set_api_key
- self.api_key = SecureRandom.base64(33) if self.api_key.nil?
+ set_api_key! if api_key.nil?
+ end
+
+ def set_api_key!
+ self.api_key = SecureRandom.base64(33)
end
# like find_by_url_name but also search historic url_name if none found