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 - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -