On 6/11/2010 2:36 AM, Dave Howell wrote:
> On Jun 11, 2010, at 0:48 , Brian Candler wrote:
>
>   
>> Dave Howell wrote:
>>     
>>> The piece I couldn't find was "How do I tell ActiveRecord to convert the 
>>> database's "UUID" type to a string, and vice versa?"
>>>       
>> Ah, I've never come across a database with a "UUID" type. I'd imagine AR 
>> would treat unknown types as strings, but you'd need to try it.
>>     
> I had to hook a special library into Postgres in order to get the UUID type. Everybody (including me) expects AR to treat it as a string, but in fact, it threw an error because the column was an unknown type. That's why I was trying to figure out how to *tell* it to treat it as a string.
>   
Strange, my version of Postgre (8.4) comes with a UUID type.
Anyway since this seems to be something we're going back and forth on
have a look at:
http://gist.github.com/434783

The output from this script will be (using Ruby 1.9.1 and PostgreSQL 8.4):
bar
foo

Sure enough, a UUID gets treated just like a string.