ruby on rails - Is there a simple way only output if variable in in a comma separated list? -


this code. want show staxcode if state in list. al,fl,co

<% @ship_states.each |state| %>   <%= state.staxcode %> <% end %> 

try,

<% @ship_states.each |state| %>   <%= ['al', 'fl', 'co'].include?(state.staxcode) ? state.staxcode : nil  %> <% end %> 

Comments