Rails around_action in the callback stack

Viewed 6850

I just discovered around_action callbacks. I don't really understand how those callbacks work with the rest, and especially how the call stack looks like compared to using (append_)before_action or prepend_before callbacks. Would the around action callback be good for an access control like this :

ApplicationController < ...

  around_action :access_control

  private

  def access_control
  if @authorized
    yield
  else
    # Show error page
  end
end

class AdminController < ApplicationController

  before_action :authorize_admins

  private

  def authorize_admins
    if current_user.admin?
      @authorizez = true
    end
  end

Does around_action behave like an append_before_action + prepend_after_action or prepend_before_action + append_after_action ?

Or something different ?

1 Answers
Related