8f5553306c2cf7f4b14153f6117f8e9b

Curious of the right way to perform this. Definitely new to ruby. Thanks!

<% if level != max_level && level > 1 %>
  <td colspan="<%=max_level-level%>" class="grouptd last"></td>
<% end %>

Refactorings

No refactoring yet !

D41d8cd98f00b204e9800998ecf8427e

foobar

April 16, 2009, April 16, 2009 20:19, permalink

1 rating. Login to rate!
content_tag(:td, '', :colspan => (max_level - level), :class => 'grouptd last') if (level > 1 && level < max_level)
8f5553306c2cf7f4b14153f6117f8e9b

Danny Peck

April 16, 2009, April 16, 2009 21:16, permalink

No rating. Login to rate!

nice, thanks.

A8d3f35baafdaea851914b17dae9e1fc

Adam

April 16, 2009, April 16, 2009 23:21, permalink

No rating. Login to rate!

Are you sure you really want to use level and max_level at all? Where are those attributes coming from?

60888d58de3bf08cbc0c73e67fd6fd86

Josh N

April 17, 2009, April 17, 2009 03:13, permalink

No rating. Login to rate!

does max_level mean the maximum? then it would be level > 0 && level < max_level which could be made a candidate for the Range#include? method

<% if (1..max_level).include?(level) %>
  <td colspan="<%=max_level-level%>" class="grouptd last"></td>
<% end %>
A8d3f35baafdaea851914b17dae9e1fc

Adam

April 17, 2009, April 17, 2009 20:32, permalink

No rating. Login to rate!

@Josh between? looks better than include? here, in my opinion.

level.between?(1, max_level)

Your refactoring





Format Copy from initial code

or Cancel