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