views:

519

answers:

1

There seems to be no shortage of questions out there about this, but it's a little more difficult to find solid answers that aren't woefully out of date. I'm taking my first (baby) steps with Rails (and Ruby, for that matter) and I'd really like to use UUIDs as my primary key. In fact, for most of my projects, it's all but essential since I frequently have to move chunks of data between one database and another.

As far as I can tell, Rails has no native means of handling this need. I'm running Ruby 1.8.6 and Rails 2.3.3. Am I missing something? Is there a later version that might offer this capability? Is it perhaps on the roadmap somewhere? Is there any other way to provide this capability? Rails is pretty much a non-starter for me (beyond the academic) without UUID support.

Being new to Ruby and Rails, I'm still learning all of the right places to look for info/answers so I may be too quick in asking this question here. Nonetheless, any insight I can get would be much appreciated.

Thanks.

+1  A: 

I don't know much about UUIDs but a quick google search yields the following:

Ruby on Rails: UUID as your ActiveRecord primary key - Ariejan.net

Try installing the UUIDTools gem and give it a whirl.

Cheers.

theIV
Thanks, theIV. That's the one I saw and will try that if there are no better suggestions. Knowing so little, I was hoping a RoR guru could offer a better way. :-)
Rob Wilkerson
If you want to look a little deeper into ActiveRecord, you can always check out the specific AR API: http://ar.rubyonrails.org/Hope some of this helps.
theIV
I was hoping for a "native" solution, but none seems to be available or even rumored. That's unfortunate, IMO.
Rob Wilkerson