在ERB中使用小于等于(< =)

时间:2015-01-29 22:38:40

标签: ruby-on-rails ruby syntax

如何用正确的ERB语法重新编写这行代码?

 <% if current_user.age == "13" and @example.thing >= 1 %>
 <h1>say this</h1>
 <% elsif current_user.age == "13" and @example.thing == 0 %>
 <h1>hello world</h1>
 <% end %>

1 个答案:

答案 0 :(得分:1)

如果您在elsif中检查了if中与此类elsif相同的条件,则应该能够在if内移动<% if current_user.age == "13"%> <h1><%= @example.thing >= 1 ? "say this" : "Hello World" %></h1> <% end %> 功能}

{{1}}