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

Fix issue MONGOID-276: do not modify options in validator in-place.

    • Type: Icon: Task Task
    • Resolution: Done
    • 12_01_17
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I believe this particular merge! was introduced by an attempt to follow the patterns seen in the shipping ActiveModel validators, which tend to use exclude(...).merge!(...) to pass options into the callback method. However, in this case we do not exclude, so the original options is never duped and is modified in place (which is the incorrect behavior).

      This went unnoticed until josevalim froze the options hash in ActiveModel upstream to detect this (common) mistake.

      This fixes the issue and prevents spurious exceptions when association validations fail using Mongoid with Rails 3.

      I submitted this as an old-style pull request earlier, but there are rumors that old-style pull requests are having issues right now (plus I wanted an excuse to try the new, shiny kind out)!

            Assignee:
            Unassigned Unassigned
            Reporter:
            bri3d Brian Ledbetter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: