RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

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

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in