Skip to content

Instantly share code, notes, and snippets.

@craigmartin
Created August 2, 2011 19:26
Show Gist options
  • Save craigmartin/1120980 to your computer and use it in GitHub Desktop.
Save craigmartin/1120980 to your computer and use it in GitHub Desktop.
Controller before_filter
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