jashmenn/activeuuid — pull request #10 by jdck (2012-08-02 15:35:45+00:00)
Title: Support for a primary column name other than 'id'

Two months ago, I needed to introduce UUIDs in a project that is currently being ported to Rails. Your gem seemed very promising, but I could not use it as-is to create a UUID column : the existing integer 'id' column in my table had to be kept as the primary key (as it is referred to by other tables). That meant I had to introduce a unique, non-primary-key UUID column named other than 'id'.

One cannot achieve this with the current version of active-uuid as the UUID column is always:
- named 'id'
- used as the primary key

With my changes, this behaviour can be overridden.

**Default behaviour**

Same as upstream: UUID is the primary key, stored in the 'id' column

```ruby
class Record < ActiveRecord::Base
include ActiveUUID::UUID
end
```

**Overriden behaviour**

UUID is not the primary key, it is stored in a column named other than 'id'.

```ruby
class Record < ActiveRecord::Base
include ActiveUUID::UUID
uuids :uuid
end
```

Note that all UUID columns declared with the `uuids` method are populated in a `before_create` callback, so using several UUID attributes works out-of-the-box.

The aforementioned overriden behaviour works fine in my application and the activeuuid test suite runs fine. However, I have not tested the default behaviour in an actual active record model.

What do you think?

Thank you very much for your time, your gem has been very useful to us.

Jean-Denis