Reputation:
How can I place an if condition in the HTML, in pseudocode, I'd like to achieve the following:
if @time.status is pending
place edit and delete below the message
else
not just display
end
This is my current code:
<% @value.each do |s| %>
<p><strong>Message:</strong>
<%= s.message %>
</p>
<p><strong>Date</strong>
<%= s.date %>
</p>
<p><strong>Status:</strong>
<%= s.status %>
</p>
<p>
<%= link_to 'Edit', value(), %>
<%= link_to 'Delete', value(), %>
</p>
Upvotes: 2
Views: 5840
Reputation: 93
It is same as your iteration
<% if @time.status=="PENDING" %>
#your html code for edit in delete
<%end%>
Upvotes: 2
Reputation: 33491
If you have access to @time and status is an attribute of it, with a value that can be "pending" (thing you didn't add in the question), then you can do:
<% if @time.status == 'pending' %>
<!-- place edit and delete -->
<% else %>
<% @value.each do |s| %>
<p>
<strong>Message:</strong>
<%= s.message %>
</p>
<p>
<strong>Date</strong>
<%= s.date %>
</p>
<p>
<strong>Status:</strong>
<%= s.status %>
</p>
<p>
<%= link_to 'Edit', value(), %>
<%= link_to 'Delete', value(), %>
</p>
<% end %>
<% end %>
Upvotes: 3