render mutates locals hash?

Jonathan Rochkind
2009-06-09T21:35:58Z

If you pass a locals hash into render() ... why would Rails mutate that
hash, adding things to it? This seems awfully odd to me.

Could have something to do with calling partials inside partials, which
I am doing. Does the locals hash ''inherit'' to the
''inner'' partial?
That''s kind of odd.

I just traced a weird bug in my app down to this -- I was storing locals
in an actual hash data structure, instead of using an anonymous hash,
and wasn''t counting on rails changing in between calls!

By "freeze"ing the thing that I didn''t expect to get
modified, I could
get this stack trace pointing to what''s doing the modifying, but I
haven''t looked at it yet.


/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/partial_template.rb:48:in
`[]=''

/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/partial_template.rb:48:in
`add_object_to_local_assigns!''

/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_view/partial_template.rb:9:in
`initialize''
--
Posted via http://www.ruby-forum.com/.