Skip to content

if create fails, it still auto increment #7

Open
@bbc4468

Description

@bbc4468

I have the following code

class SizeList
include Mongoid::Document
field :_id, type: Integer
field :name
auto_increment :sequence, :seed => -1, :step => 1
before_create { self.id = self.sequence }
end

I want the sequence to be continuous. This works really well, except in the case when create fails. It should decrease the sequence in such cases.

You should probably use after_add callback to increase the auto increment value.

Although i can still live with it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions