aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-03-15 04:19:03 +0000
committerfrancis <francis>2008-03-15 04:19:03 +0000
commit0a423eae84d6c2b123a50d2c7e8195a873aa224a (patch)
tree0b1a4e8832e63dbd7389bb9f5de5f94d518415f3 /app/models/user.rb
parentcb40d0436a2e19beaad0ec2715da97e9b8086527 (diff)
Add tests for broken case of saving info request or user when there is existing one with same title/name.
Fix the bug, which was in function that makes url_title/url_name.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 6c426c810..d3af629c3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.36 2008-03-13 11:29:47 francis Exp $
+# $Id: user.rb,v 1.37 2008-03-15 04:19:04 francis Exp $
require 'digest/sha1'
@@ -92,7 +92,7 @@ class User < ActiveRecord::Base
url_name = url_name[0..31]
end
# For request with same name as others, tag on the request numeric id
- while not User.find_by_url_name(url_name, :conditions => ["id <> ?", self.id] ).nil?
+ while not User.find_by_url_name(url_name, :conditions => self.id.nil? ? nil : ["id <> ?", self.id] ).nil?
url_name += "_" + self.id.to_s
end
write_attribute(:url_name, url_name)