Reputation: 75
i was wondering what was the best way to uniquely identify rails objects. im storing them in an index, and currently i have been doing so like
$index.document(@paper.id).add(fields, :variable => variables)
where the @paper.id uniquely identifies it. however when i store other objects, ie @card
$index.document(@card.id).add(fields, :variable => variables)
it's going to overwrite my index because im using the databases autoincrement (which is not unique because they all start and increment by 1). what would be the best solution to having unique identifiers across all my rails objects?
i looked at UUID's and had some reservations about making them my primary key like in...
http://ariejan.net/2008/08/12/ruby-on-rails-uuid-as-your-activerecord-primary-key/
i could always make a separate column i guess. or i could do something like get the object's id and then append it to creation_time. are these good ideas? if not, what would be a good solution for this?
thanks!
Upvotes: 0
Views: 395
Reputation: 91513
I would go with a composite of the object id and the name of the objects table.
Upvotes: 1