Skip to content

Instantly share code, notes, and snippets.

@sandheepg
Created March 8, 2017 07:50
Show Gist options
  • Save sandheepg/26f18158425c6808839da652558c6f0a to your computer and use it in GitHub Desktop.
Save sandheepg/26f18158425c6808839da652558c6f0a to your computer and use it in GitHub Desktop.
Difference between prepend and append filters

Note : This is as of rails 2.3.5. The methods might have been deprecated or the behavior might have changed in the latest versions of Rails.

prepend_before_filter and append_before_filter are almost the same.

They differ only in precedence. Prepend filters have higher precedence over append filters.

before_filter is an alias to append_before_filter

class MyController < ActionController::Base

before_filter :some_name #this gets called after some_other_name
prepend_before_filter :some_other_name # this gets called first

......
.....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment