Then Arlen is right - the logic should be in the model (or class that defines the row objects if they aren't coming from a classic Rails model). Something like:
Code:
def partial_to_use
if self.is_a? ClassNameA
return "ClassNameA"
else
return "ClassNameB"
end
end
Then your view simplifies to:
Code:
<% @variable_name.each do |row| -%>
<%= render :partial => row.partial_to_use -%>
<% end -%>
I'd also be tempted to change the partial names to something more descriptive like "file_row" and "text_row". So:
Code:
def partial_to_use
if self.is_a? ClassNameA
return "file_row"
else
return "text_row"
end
end
Bookmarks