Browse files

life is hard across mongoid versions with non object_id ids. use strings

  • Loading branch information...
ahoward committed Nov 3, 2011
1 parent 3994d38 commit 8a25dfecffb0f868cc14851f3a9f86c13ddff876
Showing with 18 additions and 1 deletion.
  1. +18 −1 lib/mongoid_rails_migrations/models/data_migration.rb
@@ -1,5 +1,22 @@
class DataMigration
include Mongoid::Document
# life gets harder when the id isn't a string...
field(:_id, :type => String, :default => proc{ App.uuid })
if respond_to?(:identity)
identity(:type => String, :default => proc{ App.uuid })
if respond_to?(:using_object_ids)
self.using_object_ids = false
field :version

2 comments on commit 8a25dfe


This comment has been minimized.

adacosta replied Nov 4, 2011

Hi Ara,

What's App.uuid? Care to include a test? I'm not a huge fan of the loosey goosey rescue nil. Why do we want to rescue nil? What error condition and class would cause this? In what versions did mongoid introduce :identity and :using_object_ids?

I'm full of questions. Don't take this as me denying your pull request. I'll gladly include your code if you can answer my questions while dancing a slip jig and juggling five fiery battons . I haven't used this project in awhile and don't want to anger current users by breaking the build (more than it already is).




This comment has been minimized.


ahoward replied Nov 4, 2011

I am sorry, App.uuid is not meant to be included.

Testing across the versions would be very hard to say the least. There is commentary in the mongoid repo with @duran and I regarding the preferred approaches over time... but I couldn't say which versions. I do know that this code will NOT run in mongoid 2.2.3 without this patch and that older versions should not be affected due to defined? clauses... I'll nuke this pull request and submit another. If you have a preferred strategy for testing across mongoid versions let me know: I unware of an easy way to do this...

Please sign in to comment.