如何在Ruby on Rails中使用&& in?

时间:2022-04-09 20:45:04

I tried the following && conditional for my if statement and I get a "bad range" error:

我尝试了以下&&条件为我的if语句,我得到一个“坏范围”错误:

<% if (from_today(contact, call.days) == 0..7) && (show_status(contact, call) == 'no status') %>

Why and how can I fix it? The only other way I could do it was to have a second nested if statement and break it apart...not pretty :(

为什么以及如何解决它?我能做到的唯一另一种方法是拥有第二个嵌套的if语句并将其分开......不漂亮:(

2 个解决方案

#1


12  

<% if (from_today(contact, call.days) == (0..7) && show_status(contact, call) == 'no status') %>

#2


3  

Try putting the 0..7 in parentheses. The &&is not your problem here.

尝试将0..7放在括号中。 &&这不是你的问题。

#1


12  

<% if (from_today(contact, call.days) == (0..7) && show_status(contact, call) == 'no status') %>

#2


3  

Try putting the 0..7 in parentheses. The &&is not your problem here.

尝试将0..7放在括号中。 &&这不是你的问题。