这不是评估if陈述吗?
<%= current_user.profile.name || current_user.email if current_user.profile.name.blank? %>
调试current_user.profile.name显示它是一个空字符串,但它没有打印email。像这样更改为三元运算符:
<%= current_user.profile.name.blank? ? current_user.email : current_user.profile.name %>
有效,但我想了解为什么第一种方法不起作用。