views:

163

answers:

1

In the following example,

before_filter :foo
before_filter :bar
before_filter :wah
prepend_before_filter :heehee
prepend_before_filter :haha

so then the execution orders will be:

haha, heehee, foo, bar, wah?   <-- note that haha is actually before heehee

And is there a reason not to list haha and heehee first in the first place but actually use prepend?

A: 

To my knowledge this is to solve class inheritance where you cannot define the order of the before_filter:

ApplicationController.rb << ActionController::Base    
  before_filter :do_this_first    
#....

SomeController << ApplicationController    
  before_filter :do_this_second
#.... 

Here, neither of the methods defined will have preference unless you use a prepend_before_filter.

mark