Satchel
Satchel

Reputation: 16734

How can I use && in if in Ruby on Rails?

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

<% 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 :(

Upvotes: 9

Views: 32117

Answers (2)

Dolph
Dolph

Reputation: 50690

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

Upvotes: 12

x1a4
x1a4

Reputation: 19485

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

Upvotes: 3

Related Questions