iCyborg
iCyborg

Reputation: 4728

How to bypass authentication_user for only 1 method ? (using devise)

I am using devise and in my profile_controller.rb I have the usual 7 methods and an additional methods, now I am using before_filter as only authenticated user can access those methods but for just 1 method, I need it to bypass it. How to do it ?

before_filter :authenticate_user!

def index
   ...
end

...

def destroy
   ...
end

def edit_name
   ...
end

Upvotes: 0

Views: 182

Answers (1)

collimarco
collimarco

Reputation: 35460

before_filter :authenticate_user!, except: :method_you_want_to_bypass

In this way you skip the call to authenticate_user! method when the current action is :method_you_want_to_bypass. This solution works in general, not only with Devise.

Upvotes: 1

Related Questions