Ruby Rescue vs. Try vs. Ternary
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.
Read more: https://codebrahma.com/ruby-rescue-vs-try-vs-ternary/
Comments
Don’t forget the safe navigation (lonely) operator in Ruby 2.3
Again, Raviraj, PLEASE, none of us likes shouting so avoid upcasing your article titles.
I agree with Kayolav on this. Please don’t type in all caps for titles
@Sam, you really made my day, I’ve never seen such interpretation of my name with so many mistakes in it :)
Edited @ KALOYAN
Give a try to lonely operator i.e. current_resource&.name Which seems more faster ;)
Post a comment