Created
February 16, 2009 22:16
-
-
Save coryodaniel/65408 to your computer and use it in GitHub Desktop.
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 TestUsingBeforeFilter < Application | |
before :captcha_every_time!, :only => [:create,:destroy] | |
before :captcha_once_per_30_seconds!, :only => [:index], :unless => :is_admin? | |
def index | |
render | |
end | |
def create | |
render "Awesome form here" | |
end | |
def destroy | |
render "I am the destroyer" | |
end | |
protected | |
def is_admin? | |
!!(session[:is_admin]) | |
end | |
def captcha_every_time! | |
threshold() | |
end | |
def captcha_once_per_30_seconds! | |
threshold :frequency => 1.per(30.seconds) | |
end | |
end | |
class TestUsingClassMethod < Application | |
threshold :create, :destroy | |
threshold :index, :frequency => 1.per(30.seconds), :unless => :is_admin? | |
protected | |
def is_admin? | |
!!(session[:is_admin]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment