I am having trouble with what I thought would be a simple equality
comparison.
Here is the relevant code:
<% for ticket in @tickets %>
<tr>
<% for column in Ticket.content_columns %>
<% if column.human_name == "Status" %>
<% if ticket.send(column.name).eql?("true") %>
<td>Open</td>
<% else %>
<td>Closed</td>
<% end %>
<% else %>
<td><%=h ticket.send(column.name) %></td>
<% end %>
<% end %>
My problem is as follows:
if ticket.send(column.name).eql?("true") always evaluates to false and
prints Closed.
I've also tried:
if ticket.send(column.name) == "true" but I get the same behavior.
When I try <%=h ticket.send(column.name) %> it get true
I am having trouble with what I thought would be a simple equality
comparison.
Here is the relevant code:
<% for ticket in @tickets %>
<tr>
<% for column in Ticket.content_columns %>
<% if column.human_name == "Status" %>
<% if ticket.send(column.name).eql?("true") %>
<td>Open</td>
<% else %>
<td>Closed</td>
<% end %>
<% else %>
<td><%=h ticket.send(column.name) %></td>
<% end %>
<% end %>
My problem is as follows:
if ticket.send(column.name).eql?("true") always evaluates to false and
prints Closed.
I haven't tested this, but I'm gonna guess that Ticket.status is a boolean
field, but you're comparing it to the *string* "true". What happens if
you do: