在 ERB 中使用小于等于 (<=)
Using the less-than equal-to (<=) in ERB
如何用正确的 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 %>
如果您像这样检查 elsif
中与 if
中相同的条件,您应该能够将 elsif
功能移动到初始 if
<% if current_user.age == "13"%>
<h1><%= @example.thing >= 1 ? "say this" : "Hello World" %></h1>
<% end %>
如何用正确的 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 %>
如果您像这样检查 elsif
中与 if
中相同的条件,您应该能够将 elsif
功能移动到初始 if
<% if current_user.age == "13"%>
<h1><%= @example.thing >= 1 ? "say this" : "Hello World" %></h1>
<% end %>