Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4421

Do not auto validate presence association

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.1.0
    • Component/s: None
    • Labels:
    • Environment:
      development

      I dont think association will be forced to validate automatically, I think it was incorrect logic, how can i remove it instantly ??

      $ irb
      ```
      require 'mongoid'
      => true

      class Customer
      include Mongoid::Document
      belongs_to :agent
      end

      Customer.validators
      => [#<Mongoid::Validatable::PresenceValidator:0x007fc2b04fe438 @attributes=[:agent], @options={}>]

      customer = Customer.new
      customer._validators
      => {:agent=>[#<Mongoid::Validatable::PresenceValidator:0x007fc2b04fe438 @attributes=[:agent], @options={}>]}

      customer.valid?
      => false

      customer.errors.full_messages
      => ["Agent can't be blank"]

      ```

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            yacobus Yacobus Reinhart
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: