aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2012-07-19 13:06:53 +0100
committerSeb Bacon <seb.bacon@gmail.com>2012-07-19 13:06:53 +0100
commit3ef1dd4e9f4c5c184910602c8133f81d0b0f61dc (patch)
tree89248eba2b0ccb10a89bf15da07807da1536cff3
parent8e86c94df9c68a3fb6144649e78548d411063e21 (diff)
Set api_key in before_save rather than after_initialize (to avoid errors when uploading via CSV)
-rw-r--r--app/models/public_body.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 9efeadf55..97802c7e8 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# == Schema Information
#
# Table name: public_bodies
@@ -91,8 +92,9 @@ class PublicBody < ActiveRecord::Base
# Make sure publication_scheme gets the correct default value.
# (This would work automatically, were publication_scheme not a translated attribute)
self.publication_scheme = "" if self.publication_scheme.nil?
-
- # Set an API key if there isn’t one
+ end
+
+ def before_save
self.api_key = SecureRandom.base64(33) if self.api_key.nil?
end