# Send(column.name) comparison problems

**URL:** <https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326>\
**Category:** Rails\
**Created:** [March 9, 2007, 7:56pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326 "2007-03-09T19:56:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2007, 7:56pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/1 "2007-03-09T19:56:51Z")

</div>

I am having trouble with what I thought would be a simple equality  
comparison.

Here is the relevant code:

\<% for ticket in @tickets %\>

 \<% for column in Ticket.content\_columns %\> \<% if column.human\_name == "Status" %\> \<% if ticket.send(column.name).eql?("true") %\> Open \<% else %\> Closed \<% end %\> \<% else %\> \<%=h ticket.send(column.name) %\> \<% 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

Any help would be most appreciated.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2007, 8:57pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/2 "2007-03-09T20:57:53Z")

</div>

Try this

```
  <% if column.human_name == "Status" %>
   <% if ticket.Status == "true" %>
    <td>Open</td>

```

removed\_email\_address@domain.invalid wrote:

> I am having trouble with what I thought would be a simple equality  
> comparison.
> 
> Here is the relevant code:
> 
> \<% for ticket in @tickets %\>
> 
> \<% for column in Ticket.content\_columns %\> \<% if column.human\_name == "Status" %\> \<% if ticket.send(column.name).eql?("true") %\> Open \<% else %\> Closed \<% end %\> \<% else %\> \<%=h ticket.send(column.name) %\> \<% 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
> 
> Any help would be most appreciated.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 9, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/3 "2007-03-09T23:07:22Z")

</div>

That would work too, and be a lot cleaner.

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 11:06pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/4 "2007-09-25T23:06:16Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 11:00pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/5 "2007-09-25T23:00:26Z")

</div>

> Nevermind my bad. Passing true to eql? in the proper way fixed my  
> problem.
> 
> However anyone know why == “true” wouldn’t work when the same form  
> works for checking the column name against “Status”?

> > true == “true”  
> > =\> false
> 
> > true.class  
> > =\> TrueClass
> 
> > “true”.class  
> > =\> String

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 11:11pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/6 "2007-09-25T23:11:08Z")

</div>

Nevermind my bad. Passing true to eql? in the proper way fixed my  
problem.

However anyone know why == “true” wouldn’t work when the same form  
works for checking the column name against “Status”?

On Mar 9, 11:06 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 25, 2007, 11:10pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/7 "2007-09-25T23:10:37Z")

</div>

> ```
> <td>Open</td>
> 
> ```
> 
> 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:

ticket.send(column.name).eql?(true)

?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 26, 2007, 5:14pm UTC](https://www.ruby-forum.com/t/send-column-name-comparison-problems/88326/8 "2007-09-26T17:14:27Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Nevermind my bad. Passing true to eql? in the proper way fixed my  
> problem.
> 
> However anyone know why == “true” wouldn’t work when the same form  
> works for checking the column name against “Status”?

“true” is the string with the letters t,r, u and e. Not in anyway  
related to the boolean value true (except in the way that anything non  
nil is true in ruby. the column’s name is however just a string.

> if ticket.send(column.name)

would be enough

Fred
