Commit 78becdf15894f7e5ca4657a1149ec745dcf956e4

Authored by Nick Recobra
1 parent 01121261
Exists in master and in 1 other branch production

Generating app id on create so Mongoid won't consider it a BSON::ObjectID.

Showing 1 changed file with 7 additions and 1 deletions   Show diff stats
app/models/app.rb
... ... @@ -7,7 +7,13 @@ class App
7 7 field :resolve_errs_on_deploy, :type => Boolean, :default => false
8 8 # Some legacy apps may have sting as key instead of BSON::ObjectID
9 9 identity :type => String
10   -
  10 + # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature:
  11 + # https://github.com/mongoid/mongoid/issues/703
  12 + # Using 32 character string as a workaround.
  13 + before_save :on => :create do |r|
  14 + r.id = ActiveSupport::SecureRandom.hex
  15 + end
  16 +
11 17 embeds_many :watchers
12 18 embeds_many :deploys
13 19 references_many :errs, :dependent => :destroy
... ...