Test if string is not equal to either of two strings Test if string is not equal to either of two strings ruby ruby

Test if string is not equal to either of two strings


This is a basic logic problem:

(a !=b) || (a != c) 

will always be true as long as b != c. Once you remember that in boolean logic

(x || y) == !(!x && !y)

then you can find your way out of the darkness.

(a !=b) || (a != c) !(!(a!=b) && !(a!=c))   # Convert the || to && using the identity explained above!(!!(a==b) && !!(a==c)) # Convert (x != y) to !(x == y)!((a==b) && (a==c))     # Remove the double negations

The only way for (a==b) && (a==c) to be true is for b==c. So since you have given b != c, the if statement will always be false.

Just guessing, but probably you want

<% if controller_name != "sessions" and controller_name != "registrations" %>


<% unless ['sessions', 'registrations'].include?(controller_name) %>

or

<% if ['sessions', 'registrations'].exclude?(controller_name) %>