# Render dynamically vertical tabs and set classes depends on if statement

I would like to refactor code below and get rid of if statements for classes from view.

.container
.tabbable.tabs-left
%ul.nav.nav-tabs

.tab-content


Helper methods are good for this. In your view's helper file:

def task_link_class(task)
''
else
'inactive'
end
end


Some would prefer the trinary operator instead:

def task_link_class(task)

= link_to task.name, "#tab#{task.id}", data: { toggle: 'tab' }, class: task_link_class(task)

• Its my understanding that using @instance_variables in helpers is not a good practice. Better pass values as arguments. – tokland Jan 7 '14 at 19:09