如果条件不适用于&&运算符

时间:2019-12-25 14:03:22

标签: ruby-on-rails ruby

还显示了其中receive_by_admin为True的订单链接。

if order.payment_status == 'Paid' && order.received_by_admin != 'true'
   link_to "Payment Received", "orders/#{order.id}/?payment_status=Paid", class: "member_link", method: :put
end

1 个答案:

答案 0 :(得分:2)

可能是因为received_by_admin是布尔值吗?所以

order.payment_status == 'Paid' && order.received_by_admin != true

或更简单

order.payment_status == 'Paid' && !order.received_by_admin

这里的重点是true != 'true'