Rails does not detect the primary key value of new saved objects
when the primary key is not a sequence, and the value is generated
by another default function.
Table "public.moo"
Column | Type | Modifiers
--------+-----------------------+-------------------------------------
id | uuid | not null default uuid_generate_v4()
moo | character varying(64) |
Indexes:
"moo_pkey" PRIMARY KEY, btree (id)
This works perfectly when using the postgresql command line;
INSERT INTO moo(moo) VALUES('moo') RETURNING id;
id
--------------------------------------
9a5374a9-0bf3-4196-b68b-e1dd6ab69f69
(1 row)
INSERT INTO moo(moo) VALUES('moo') RETURNING id;
id
--------------------------------------
a107f5da-f013-4c15-83e8-fb0220fa3918
(1 row)
etc..
When using the framework the id isn't retrieved:
irb(main):006:0> blah = Moo.create(:moo => 'testing123')
=> #<Moo id: nil, moo: "testing123">
irb(main):007:0> Moo.find_by_moo('testing123')
=> #<Moo id: "c4c3ea70-61d9-4d4b-baae-aa6adde0b58b", moo: "testing123">
Tested with Rails 3.0.3 and PostgreSQL 8.3.12.