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

Calling destroy in after_save callback throws an error

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.5.0
    • Affects Version/s: None
    • Component/s: None

      So I have a model and I am doing some validation inside after_save callback, if the validation fails I need to call the destroy method on the model. But when I do that, I get this error?

      Mongoid::Errors::Callback: Calling save! on ChatMessage resulted in a false return from a callback.
      	from /Users/kapilisrani/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.10/lib/mongoid/persistence.rb:267:in `fail_callback!'
      	from /Users/kapilisrani/.rvm/gems/ruby-1.9.3-p194/gems/mongoid-2.4.10/lib/mongoid/persistence.rb:77:in `save!'
      	from (irb):128
      

      Using Mongoid 2.4.10 with Rails 3.2.6

            Assignee:
            Unassigned Unassigned
            Reporter:
            kapso kapso
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: