我在使用简单的IF语句时遇到问题。我尝试了几件事并没有成功。
<% if item.ITEM.strip != 'OEM-LABELS' || item.ITEM.strip != 'DISCOUNT' || item.ITEM.strip != 'OEM-DVR' %>
<% if item.ITEM.strip != 'OEM-LABELS' or item.ITEM.strip != 'DISCOUNT' or item.ITEM.strip != 'OEM-DVR' %>
答案 0 :(得分:0)
如果我是你,我会简化如下
item = "A"
["C","B","A"].include?item #=> true
["C","B","D"].include?item #=> false
if ["C","B","D"].include?item
do something
或
if !["C","B","D"].include?item
do something
答案 1 :(得分:0)
嘿,所以很少(不用看你的代码)
为此逻辑
创建一个帮助器def needs_discounting(item)
LOGIC HERE
end
然后在你看来
<% if needs_discounting(item.ITEM) %>
STUFF
<% end %>