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

Implement :on option in callbacks

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Callbacks
    • Labels:

      ActiveRecord allows:

      after_commit on: %i(create update) { do_something }
      

      Trying this in Mongoid (with after_save instead of after_commit) produces:

      Failure/Error: after_save(on: %i[ create update ]) { attachment_changes.delete(name.to_s).try(:upload) }
      
      ArgumentError:
        Unknown key: :on. Valid keys are: :if, :unless, :prepend
      

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: