Rajat
Rajat

Reputation: 1836

rails Do not call before_filter for a specific URL

I am defining a before_filter :authorize_special_user, which checks if the special condition exists or not. If yes, then it is okay, otherwise I redirect to a URL like "/users/special#account". So how do I specify the before_filter to NOT be called on the URL "/users/special#account"? Normally it is done by

before_filter :authorize_special_users :except => [ :users ]

But it will not work here. I tried

before_filter :authorize_special_users :except => [ "/users/special#account" ]

but it does not work either.

Upvotes: 0

Views: 1039

Answers (1)

cdesrosiers
cdesrosiers

Reputation: 8892

An alternative solution would be to wrap the code inside the before filter in a conditional:

def authorize_special_users
    unless request.path == "/users/special"
        ...
    end
end

Upvotes: 1

Related Questions