From a843cfff36d6221fc3d1ab025300c14912acb25d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 30 Jan 2010 10:26:30 +0000 Subject: [PATCH] Merged r3343 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/0.9-stable@3344 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/principal.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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