This project is archived and is in readonly mode.

#3471 ✓wontfix
Mislav

ActionView#assigns lost its usefulness

Reported by Mislav | November 9th, 2009 @ 12:08 AM | in 3.0.2

In Rails 2.3.4 I was able to do something in the lines of:

@view = ActionView::Base.new
# later:
@view.assigns[:foo] = 'bar'
# finally:
@view.render(:inline => @template, :locals => locals)

That is, update the assigns list after instantiation and have it affect the rendering.

In Rails 3, the assigns hash is copied to local instance variables immediately in the initializer. This hash is copied to @assigns and exposed through an #assigns accessor like before, but this object is never used internally again and thus writing to it has no effect. The only way to pass assigns now is during the initialization:

@view = ActionView::Base.new([], @assigns)

This seems like a regression because the old way was certainly useful.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages