This project is archived and is in readonly mode.

#5648 ✓resolved
Buts Johan

after_filter not halted

Reported by Buts Johan | September 17th, 2010 @ 01:39 PM | in 3.0.2

Expected behavior:

When a before filter render or redirects the action itself and after filters should not be executed.

Wrong behavior:

After filter gets executed although the before filter rendered or redirected.

Example:

In following application_controller.rb ...

class ApplicationController < ActionController::Base

  before_filter :do_before
  after_filter  :do_after

  def should_halt
    Rails.logger.debug "Executed: should_halt"
    render :text => 'not halted'
  end

  def do_before
    Rails.logger.debug "Executed: do_before"
    render :text => 'before'
  end

  def do_after
    Rails.logger.debug "Executed: do_after"
  end

end

expected debug output should be:

Executed: do_before

but was

Executed: do_before
Executed: do_after

Note:

Rails 2.0 documentation indicated that after filters should not get called when before filters returned false, rendered or redirected. The current rails documentation (3.0) does not document the behavior of the controller callbacks. Either indicate that the behavior has changed or that this bug needs to be fixed.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages