Skip to content

seq_name should follow collection name not class name #18

Open
@satnami

Description

@satnami

Caused by

The issue appear after changing the class name, let's say

class Documents
  include Mongoid::Document
  
  auto_increment :sequence
  
  store_in collection: 'document'
end

here the seq_name = 'documents'

class Document
  include Mongoid::Document
  
  auto_increment :sequence
  
  store_in collection: 'document'
end

but here the seq_name = 'document'

Solution

seq_name = options[:name] || "#{self.name.downcase}_#{name}"

to

      seq_name  = options[:name] || "#{self.collection.name.downcase}_#{name}"

Note

this will break backward compatibility

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions