summaryrefslogtreecommitdiffstats
path: root/app/models/principal.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-30 10:24:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-30 10:24:23 +0000
commit12ea682b6639fd084a1ef7dacae8fa9531a0d0c6 (patch)
treeff5b8340bf0f15652183db80c1261dc78bad1499 /app/models/principal.rb
parent8420f251099ad855bd347e3f687471f18ee40df4 (diff)
downloadredmine-12ea682b6639fd084a1ef7dacae8fa9531a0d0c6.tar.gz
redmine-12ea682b6639fd084a1ef7dacae8fa9531a0d0c6.zip
Fixed: NOT NULL constraint error when adding a group (#4632).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3343 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/principal.rb')
-rw-r--r--app/models/principal.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/principal.rb b/app/models/principal.rb
index 37d2a545d..8b46c7ff9 100644
--- a/app/models/principal.rb
+++ b/app/models/principal.rb
@@ -32,6 +32,8 @@ class Principal < ActiveRecord::Base
}
}
+ before_create :set_default_empty_values
+
def <=>(principal)
if self.class.name == principal.class.name
self.to_s.downcase <=> principal.to_s.downcase
@@ -40,4 +42,16 @@ class Principal < ActiveRecord::Base
principal.class.name <=> self.class.name
end
end
+
+ protected
+
+ # Make sure we don't try to insert NULL values (see #4632)
+ def set_default_empty_values
+ self.login ||= ''
+ self.hashed_password ||= ''
+ self.firstname ||= ''
+ self.lastname ||= ''
+ self.mail ||= ''
+ true
+ end
end