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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - How can I echo out this array? -

javascript - IE11 incompatibility with jQuery's 'readonly'? -