Created
August 2, 2011 19:26
-
-
Save craigmartin/1120980 to your computer and use it in GitHub Desktop.
Controller before_filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
# use code block as filter | |
before_filter do |controller| | |
controller.send(:intruder?) # call intruder? method in the controller | |
# ... | |
end | |
def intruder? | |
# ... | |
end | |
end | |
# another example: | |
class WeblogController < ActionController::Base | |
before_filter { |controller| head(400) if controller.params["stop_action"] } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment