All of us have faced this situation when, the current_resource object provided by devise turns out to be nil. All method invocations on current_resource on current_resource will throw an undefined method for nil:NilClass exception.
To handle this, we can try one of the following.
But, what is the most efficient way? Let’s find out.
Note that rescue is considerably inefficient compared to the other two (almost 60 times). The Ternary operator seems to be the most sound option.