Active record, postgresql sequences and primary keys

Hello all.
I have a question about using active record and postgresql sequences.

What part of it does not work? Are you getting any error messages?

When I save account, id = null, and postgresql swears that id is null.
I have id field:
id bigint NOT NULL,

I want that active record invoke sequence and insert new primary key to
id property.

I have changed accounts table and add constraints:

I have change type of ID: bigint -> to serial and all work now.
But my legacy DB has id as bigint.
How can I invoke sequence from code?

I don't know the full answer, but I think you may have to use
set_primary_key in your model. Google for rails legacy database and
you may find some helpful links.

Colin