Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

inconsistent support in assigns API

#4431

On http://github.com/rails/rails/blob/master/actionpack/lib/action_con..., the docs say you can access assigns with assigns(:key).

It turns out that you can actually access assigns in any of these three ways:

assigns(:key)
assigns("key")
assigns["key"]

But you can not access assigns with assigns[:key]. Actually, you can use assigns[:key], but it always returns nil, leading to false results in tests with no indication that you're doing something wrong.

My thought is that if you can use strings or symbols with assigns(...), you should probably be able to use strings or symbols with assigns[...]. The alternative would be to prevent access with keys (or warn in that case), but that seems like overkill to me.

Here's a patch to handle the more flexible case:

http://github.com/dchelimsky/rails/commit/9531c36bbc681b5b905f695b8...

Reported by David Chelimsky · April 17th, 2010 @ 08:55 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none