2015-07-03 25 views
-1

我遇到了簡單的IF語句問題。我曾嘗試過幾件事情,但沒有成功。紅寶石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

如果我是你,我會簡化如下

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 
0

嘿那麼幾件事情(不看更多的代碼的)

  1. 爲此邏輯創建一個幫手

    def needs_discounting(item) 
        LOGIC HERE 
    end 
    
在你看來

然後

<% if needs_discounting(item.ITEM) %> 
     STUFF 
    <% end %>