Dynamic collection name incorrectly writes when using validates_uniqueness_of

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 3.0.2
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      class SomeModel
        include Mongoid::Document    
      
        field :somefield
      
        validates_uniqueness_of :somefield
      end
      
      SomeModel.with(collection: 'new_name').create({ 'key' => 'val' }) 
      

      When dynamically setting the collection name using with if theres a call to validates_uniqueness_of the record will automatically be written to the "some_model" collection instead of the "new_name" collection. No error or warning is thrown. This does not seem like the desired behavior. Is there another way to handle uniqueness of fields in dynamic collection names?

              Assignee:
              Unassigned
              Reporter:
              adamgotterer
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: