Currently I have a users and an assets table (postgres backend), when a user creates a new asset it populates the asset id as expected 1, 2, 3, etc. which is displayed as ###1 based on our current asset tagging method.

As part of the asset management system we need to import assets that have been exported from our current system. I'm using roo and find_by_or_initialize to create these assets using their current id. However when I go to add a new asset it uses the first free id and uses that instead of using the next in the sequence. This wouldn't be an issue but there about 200 missing numbers in the existing management system and I can't think of a solution other than manually adding them at the moment.

Is there a way to make the id not use the first blank for instance; 1, 2, 6, 7, 8, 12?

This is the create method for the assets

def create @asset = current_user.assets.build(params[:asset]) if @asset.save redirect_to root_path flash.now[:success] = "Asset created!" else render 'static_pages/home' end end

This is the method used to import existing assets

def self.import(file) spreadsheet = open_spreadsheet(file) header = spreadsheet.row(1) (2..spreadsheet.last_row).each do |i| row = Hash[[header, spreadsheet.row(i)].transpose] asset = find_or_initialize_by_id(spreadsheet.cell(i, 'A')) || new asset.attributes = row.to_hash.slice(*accessible_attributes) asset.save! end end

EDIT: And this is an example of the current behaviour