From 78becdf15894f7e5ca4657a1149ec745dcf956e4 Mon Sep 17 00:00:00 2001 From: Nick Recobra Date: Wed, 16 Mar 2011 19:58:22 +0300 Subject: [PATCH] Generating app id on create so Mongoid won't consider it a BSON::ObjectID. --- app/models/app.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/app.rb b/app/models/app.rb index d928bc0..e7b3fae 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -7,7 +7,13 @@ class App field :resolve_errs_on_deploy, :type => Boolean, :default => false # Some legacy apps may have sting as key instead of BSON::ObjectID identity :type => String - + # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature: + # https://github.com/mongoid/mongoid/issues/703 + # Using 32 character string as a workaround. + before_save :on => :create do |r| + r.id = ActiveSupport::SecureRandom.hex + end + embeds_many :watchers embeds_many :deploys references_many :errs, :dependent => :destroy -- libgit2 0.21.2