I am working with Rails 4 application. I have Users model and Operators Model (this is like a super Admin). Have a controller say testcontroller which has the following filter to validate the user has been authenticated.
before_filter :authenticate_user!
Now I have to access this testcontroller as Operator too. (in my case the Authentication of User and Operator are different). When I try to access, as my session would be current_operator, the controller's before_filter which has autheticate_user! is stopping me.
I tried adding the blow code to the testcontroller
before_filter :check_operator
#before_filter :authenticate_user!
private
def check_operator
if current_operator!=nil
:authenticate_operator!
else
:authenticate_user!
end
end
And still not able to access testcontroller as Operator. Any thoughts would help me a lot
I may have some ideas on this :
authenticate_user!check_operatorwill never fall inauthenticate_user!as you will always fall inauthenticate_operator!NB : You should use
before_action, it is the new syntax forbefore_filter:)