问题描述:

This is my code.

What I want to do is only show STAXCODE if the state is in this list. AL,FL,CO

<% @ship_states.each do |state| %>

<%= state.STAXCODE %>

<% end %>

网友答案:

try,

<% @ship_states.each do |state| %>
  <%= ['AL', 'FL', 'CO'].include?(state.STAXCODE) ? state.STAXCODE : nil  %>
<% end %>
相关阅读:
Top