Dylan L.
Dylan L.

Reputation: 1317

Using the less-than equal-to (<=) in ERB

How can I rephrase this line of code in the proper ERB syntax?

 <% 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 %>

Upvotes: 0

Views: 2285

Answers (1)

Brennan
Brennan

Reputation: 5732

If you are checking the same condition in your elsif that you did in your if like this, you should be able to move the elsif functionality inside the initial if

<% if current_user.age == "13"%>
  <h1><%= @example.thing >= 1 ? "say this" : "Hello World" %></h1>
<% end %>

Upvotes: 2

Related Questions