views:

43

answers:

2

Hi,

I've an element TR in my view, I want to add classes dynamically on this element depending on an association between 2 models (many to many between company and packaging).

The result should looks like

<tr class="pck1 pck3 pck5">

where pck1, pck3 and pck5 are packaging associated with a company

Thanks for your insights

+2  A: 

Say you have an array classes = ['pck1', 'pck3', 'pck5'] with the classes you want your tr to have.

Just type something like:

%tr{:class => classes.join(' ')}
Hugo Peixoto
thanks for your help!
denisjacquemin
+3  A: 

or simply:

%tr{ :class => classes }
KARASZI István
thanks for your help!
denisjacquemin