Have a rails app (3.0.9) using HAML, local development server runs fine. But when I run rails s -e production, my page gives this error:
NoMethodError: undefined method `+@' for #<String:0x00000006331098>
The error says it is on this line (from the view, written in HAML):
%tr{:class=> cycle("even","odd")}
I'm not finding anything about why this is happening. Please help.
Does the cycle
method do any sort of string concatenation?
I encountered this error recently during a code review.
The code was something like this:
anObject.instance_method +string_var
The instance_method
was returning a string which was to be appended with the string value present in variable string_var
.
Changing the code to this worked
anObject.instance_method + string_var
# Note the space after the +
Without space the unary +
method is invoked on the string_var, but no unary +
method is defined on the String class. Hence the exception.
Note that the unary +
method is defined as def +@
, hence the exception message says "Method +@
not found".
This gist makes it clear : https://gist.github.com/1145457
Anyways, in your case, the method cycle
(do not know whether it is defined by you or is part of a gem) is probably doing some string concatenation without proper spacing OR the exception backtrace is not pointing to the right line of code.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With