DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-09 18:06 UTC
send(column.name) comparison problems
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 Any help would be most appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-09 18:10 UTC
Re: send(column.name) comparison problems
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, "DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > Any help would be most appreciated.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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: ticket.send(column.name).eql?(true) ?> > 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. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-09 18:24 UTC
Re: send(column.name) comparison problems
Thanks! On Mar 9, 11:25 am, Philip Hallstrom <r...-SUcgGwS4C16SUMMaM/qcSw@public.gmane.org> 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 == "true" > => false > >> true.class > => TrueClass > >> "true".class > > => String > > > > > On Mar 9, 11:06 am, "DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > >> 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 > > >> Any help would be most appreciated.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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> > On Mar 9, 11:06 am, "DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> 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 >> >> Any help would be most appreciated. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Try this <% if column.human_name == "Status" %> <% if ticket.Status == "true" %> <td>Open</td> DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> 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 > > Any help would be most appreciated.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-09 22:06 UTC
Re: send(column.name) comparison problems
That would work too, and be a lot cleaner. Thanks! On Mar 9, 12:57 pm, Steven <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Try this > > <% if column.human_name == "Status" %> > <% if ticket.Status == "true" %> > <td>Open</td> > > > > DamnBig...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > 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 > > > Any help would be most appreciated. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
DamnBigMan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---