Problem: We had a line like “errors = errors or hash.key? (:symbol)” and errors just wouldn’t become “true”, even if the expression “errors or hash.key? (:symbol)” evaluated to “true”.
Solution: You have use “errors = (errors or hash.key? (:symbol))” or probably “errors = errors || hash.key? (:symbol)” .
Explanation: The keyword is operator precedence. It seems the “=”-operator has a higher precedence than the “or”-operator, so the line is evaluated as if one writes “(errors = errors) or hash.key? (:symbol)”. That means ruby just assigns “errors” to “errors” and then evaluates the whole statement. By using parentheses or the “||”-operator the right side of the “=”-operator has a higher precedence and is evaluated first, then assigned to the left side.
References: Here is where we found the solution: http://adamloving.com/internet-programming/ruby-boolean-operator-or-ruby-parsing-bug