Every time you switch between comparing a single value versus comparing multiple values, you have to switch the variable and values around.
return if params[:controller] == 'users'
return if ['users', 'sessions', 'admin'].include? params[:controller].
The following reverses the syntax of Array#include?
class Object
def in?(arr)
arr.include? self
end
def not_in?(arr)
!(arr.include? self)
end
end
Now you could say:
return if params[:controller] == 'users'
return if params[:controller].in? ['users', 'sessions', 'admin']
Is there a better/safer way to do this without playing with the Object class?
Why not just invert the other case to match?
Besides lining up with the multi-value case, it avoids accidental use of the assignment operator
=instead of the equality operator==.