Wierd Rails 2.0.2 bug

If you’re getting “stack level too deep” errors… it might be this… this was an extra fun way to spend an hour:

This generates a stack too deep error
blogs.collect {|u| [ u.title, u.id ] }

This doesn’t
blogs.collect {|u| [ u.title, u[:id] ] }

Some discussion on Riding Rails – but no explanations.

1 Comment

KippJanuary 3rd, 2008 at 7:30 pm

Who said that perl was hard to read? I cannot for the life of me figure out what that syntax after “collect” means. Does that create a local variable “u” and use it to create an array contains a title and, I’m guessing, an id. Whatever it is, it is not very clear.

Remember this is coming from someone who doesn’t know Ruby or Rails at all. hehe