I''m using a relatively simple erb to generate output. However, though it works, it also produces a lot of ''false'' words in the output. This is easier shown than described. Here is the erb: <h1>Image Search page</h1> You can use this page to search for particular images in the GRECC collection of images, by specifying particular properties you are interested in. <% form_tag ''/test'' do -%> <hr/> <h2>Select Series of Interest:</h2> <table> <% counter = 0 %> <% @series.each do |k| %> <%= counter%4==0 ? "<tr>" : "" %> <td><small><%= k+":" %><%= check_box_tag @seriesmap[k] %></small></ td> <%= counter%4==3 and counter > 1 ? "</tr>" : "" %> <% counter += 1 %> <% end %> </table> <br /> <hr/> <h2>Select Years of Interest:</h2> <% @years.each do |y| %> <%= y.to_s + ":" %> <%= check_box_tag y.to_s %> <% end %> <hr/> <div><%= submit_tag ''Search'' %></div> <% end -%> ------------------------- And here is the first part of the generated output: h1>Image Search page</h1> You can use this page to search for particular images in the GRECC collection of images, by specifying particular properties you are interested in. <form action="/test" method="post"><div style="margin:0;padding: 0"><input name="authenticity_token" type="hidden" value="9d151f1fc0d7db4d2797c4b49517ab0def669cfa" /></div><hr/> <h2>Select Series of Interest:</h2> <table> <tr> <td><small>(7313/102/1)+(7313/6/76):<input id="seriesB" name="seriesB" type="checkbox" value="1" /></small></td> false <td><small>(7313/7/40)+(7313/103/1):<input id="seriesB" name="seriesB" type="checkbox" value="1" /></small></td> false <td><small>+C 1.5mmAxT13dspgr:<input id="seriesB" name="seriesB" type="checkbox" value="1" /></small></td> false ----------------------- Anyone know where those ''false''s are coming from? It''s got me stumped. Thanks, Ken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 1, 8:14 pm, Kenneth McDonald <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> wrote:> <%= counter%4==3 and counter > 1 ? "</tr>" : "" %> > > Anyone know where those ''false''s are coming from? It''s got me stumped. >The line above is the culprit, and the problem is that you have used and instead of &&. and has very low precedence, so the above is equivalent to (counter%4==3) and (counter > 1 ? "</tr>" : "") (ie the whole expression evaluates to false if counter is not congruent to 3 mod 4) && has higher precedence, replacing the and with && would make it equivalent to ((counter%4==3) and (counter > 1)) ? "</tr>" : "") which is what you want. Fred --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ah, many thanks, I was thinking the difference between && and ''and'' was bitwise vs. logical. Ken On Oct 1, 2008, at 4:20 PM, Frederick Cheung wrote:> > > > On Oct 1, 8:14 pm, Kenneth McDonald <kenneth.m.mcdon...-rphTv4pjVZMJGwgDXS7ZQA@public.gmane.org> > wrote: >> <%= counter%4==3 and counter > 1 ? "</tr>" : "" %> >> >> Anyone know where those ''false''s are coming from? It''s got me >> stumped. >> > > The line above is the culprit, and the problem is that you have used > and instead of &&. and has very low precedence, so the above is > equivalent to > > (counter%4==3) and (counter > 1 ? "</tr>" : "") > > (ie the whole expression evaluates to false if counter is not > congruent to 3 mod 4) > > && has higher precedence, replacing the and with && would make it > equivalent to > > ((counter%4==3) and (counter > 1)) ? "</tr>" : "") > > which is what you want. > > Fred > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---