views:

21

answers:

0

I'm working on a legacy database system where the primary key, for some strange reason, starts with 1 and is not set to AUTO INCREMENT and the next value is always max primary key + 1 (the primary key is still an integer). Furthermore, the primary key names are all custom and set by set_primary_key.

Now I want to map ActiveRecord to it and fit as if it where powered by the old database abstraction, but I just can't find a way to overcome this serious limitation.

I tried to use before_save and manually calculate the id, but it would break even the simplest has_many and has_one mapping. Maybe you guys got some good ideas?