From 0c9f041f28b57d1f0259521a294f0c65f4dd24ec Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:42:37 -0700 Subject: [PATCH 1/4] we need do bad things in the user for seeding the database --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 56f7882d1..b9b03dede 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,7 @@ class User many :groups, :class_name => 'Group' + before_validation :do_bad_things after_validation_on_create :setup_person ######## Making things work ######## @@ -302,7 +303,11 @@ class User terse = terse.chop! if terse[-1, 1] == '/' terse end - + + def do_bad_things + self.password_confirmation = self.password + end + def visible_person_by_id( id ) id = ensure_bson id return self.person if id == self.person.id From 0f6ec71dcd37fbc0ec170dba258ffad2a08f9fad Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:45:41 -0700 Subject: [PATCH 2/4] we need assign key as well --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index b9b03dede..7f4ea5c98 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,6 +16,7 @@ class User many :groups, :class_name => 'Group' + before_validation_on_create :assign_key before_validation :do_bad_things after_validation_on_create :setup_person From 0a3277d3069df0228019d9abf33b761ced24a67d Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:51:51 -0700 Subject: [PATCH 3/4] maybe the instantiate method will help --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 7f4ea5c98..9c88b8462 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -297,7 +297,12 @@ class User end ###Helpers############ - + def self.instantiate( opts = {} ) + opts[:person][:email] = opts[:email] + opts[:person][:serialized_key] = generate_key + User.create( opts) + end + def terse_url terse= self.url.gsub(/https?:\/\//, '') terse.gsub!(/www\./, '') From 9e78c9b64c686df1f066b59f16113c0aadb88a69 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 21:58:29 -0700 Subject: [PATCH 4/4] removing setup person --- app/models/user.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9c88b8462..a8f7c3c52 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -18,7 +18,6 @@ class User before_validation_on_create :assign_key before_validation :do_bad_things - after_validation_on_create :setup_person ######## Making things work ######## key :email, String