Turning off ID's auto_increment

For one of my objects it's 'id' will be taken from another system so I
don't want it auto_incrementing but I want to just assign a value
myself to it? How can I create an id field while turning off
auto_increment for it within a migration?

Thanks my friends :-).

It works and it does not work :-).

For some reason rails still does not like me assigning a value to id
even if it is not a primary key. How can I resolve this?

John –

You didn’t say what type of database you are using, but the place you should look is on ActiveRecord::ConnectionAdapters::AbstractAdapter – prefetch_primary_key?() and next_sequence_value(). You should probably look at subclassing this class, and returning false from prefetch_primary_key?. That will cause next_sequence_value to be called, and you can do what you need to there. The return from this function is assigned to the id of the ActiveRecord instance.

Take a look at the firebird or openbase adapters for examples.