I have current_patient
which has been created by devise. i have used this in a lot of places around my app.
However i now want to add a condition into this method (to check for current_admin aswell). So i was thinking of overwriting the current_patient
method in the application controller.
So basically the method would look like:
def current_patient
current_patient || current_admin
end
Im going for this approach rather than creating a new method called current_patient_or_admin
for example, because i don't want to have to replace every place where current_patient
is being called.
However i'm aware that the above snippet will not work as it will create an infinite loop, so i was wondering if anyone has any idea about how to do this?
I have also tried using an alias_method but i believe that it will cause the same problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…