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

validates_presence_of executes other validations

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 12_01_17
    • Component/s: None
    • Labels:

      Description

      class Item
         belongs_to :user, inverse_of: :items, index: true
         validates_presence_of :user
      

      When I validates_presence_of is called, it triggers execution of all validations on user as well - something I don't expect.

      For the reference, the inverse looks like this:

      class User
         has_many :items, inverse_of: :user
         validate :my_custom_validation_that_gets_called
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            emirkin Eugene Mirkin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: