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

Validation attribute "on" only accept a string not a symbol

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

      According http://mongoid.org/en/mongoid/docs/validation.html you can do something like

      validates :foo, presence: true, on: :create
      validates :bar, presence: true, on: :update
      

      what is in consistence with the behaviour of active record. But in my case (mongoid-4.0.1) it failed. After fiddling around I found out that it works with strings.

      validates :foo, presence: true, on: 'create'
      validates :bar, presence: true, on: 'update'
      

      So in my honest opinion, I state this as a minor bug. When I have time, I'll fix it but in the mean this ticket should be a hint for other users stepping in this trap.

            Assignee:
            Unassigned Unassigned
            Reporter:
            gurix Markus Graf
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: