Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Returning false in around_* callback still firing after_* callbacks? #7127

jingoro opened this Issue · 6 comments

5 participants


When returning false in an around_* callback, this will halt the chain and prevent the method from being executed. However, after_* callbacks are still being triggered. This behavior does not occur with before_*.

Here is some example code:

require 'active_model'

class A
  extend ActiveModel::Callbacks
  define_model_callbacks :create
  def create; run_callbacks(:create) { p 'create A' }; end
  before_create { false }
  after_create { p 'not here' }

class B
  extend ActiveModel::Callbacks
  define_model_callbacks :create
  def create; run_callbacks(:create) { p 'create B' }; end
  around_create { false }
  after_create { p 'but here?' }

a =; p a.create
b =; p b.create

This results in:

"but here?"

This was tested on both ActiveModel 3.2.6 and ActiveModel on master. Is this a bug or expected behavior?

See mongoid/mongoid#2198


I'm not quite sure if this is an expected behavior. I only can find a single test, actually saying that the after callback shouldn't be executed:


My inclination is that this is a bug for a couple reasons:

  1. If you return false in a before callback, it stops execution (of save) and does not execute any after callbacks.
  2. Returning false in the around callback before yield does stop execution (of the save), and causes save to return to false. Thus, it would seem more natural that it would follow the same pattern of a before callback and not execute any after callbacks.

@jingoro I sent the above PR. Please confirm it.


@kennyj Just left a note on #8479 confirming the PR.

@jingoro jingoro added the stale label

This issue has been automatically marked as stale because it has not been commented on for at least
three months.

The resources of the Rails team are limited, and so we are asking for your help.

If you can still reproduce this error on the 4-1-stable, 4-0-stable branches or on master,
please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions.

@rafaelfranca rafaelfranca added attached PR and removed stale labels
@rafaelfranca rafaelfranca self-assigned this
@sgrif sgrif closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.