Вопрос

I have this statement :

username.blank? ? firstname : username

There is a shortcut or a way to avoid repeating 'username' ?

Это было полезно?

Решение

As it seems you're using ActiveSupport, there is simple way to do this:

username.presence || firstname
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top