undefined method `+@' for " ":String
Submitted by greg on Mon, 06/16/2008 - 21:23
After trying a few things, I realized that Rails (Ruby, really) was complaining that the ' ' operator wasn't at the end of the line, so it wasn't trying to concatenate the strings as I expected. So flipping them to the end of the line fixed the error.
I was tired, or maybe I would've started that way. In any case, hopefully this will let someone else save a few moments. Live and learn.
I came across this less-than-helpful message while working on a little Rails app (hopefully more to come on that later!):
undefined method ` @' for " ":String
The code was something like:
html = '<label>'
+ check_box_tag("responses[#{code}][#{ans}]", ans)
+ ' ' answer '<label>'After trying a few things, I realized that Rails (Ruby, really) was complaining that the ' ' operator wasn't at the end of the line, so it wasn't trying to concatenate the strings as I expected. So flipping them to the end of the line fixed the error.
html = '<label>' +
check_box_tag("responses[#{code}][#{ans}]", ans) +
' ' answer '<label>'I was tired, or maybe I would've started that way. In any case, hopefully this will let someone else save a few moments. Live and learn.














Comments
Thanks for that tip. I had
Thanks for that tip. I had the same + sign at the beginning of the line!
Post new comment