I have an \'Account\' model in Rails with its corresponding \'accounts\' table in the database. If I wipe the database and start over, the \'account_id\' field will always star
A pure Ruby, database-independent approach could be:
class MyModel before_create do self.id = [1000, (self.class.maximum(:id) || 0) + 1].max if self.id.nil? end end
When you're creating lots of records at once, this may not perform so well though.