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.

ActionView#assigns lost its usefulness

#3471

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.

Reported by Mislav · November 9th, 2009 @ 12:08 AM

State: wontfix
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • Assigned user set to Yehuda Katz (wycats)

    November 9th, 2009 @ 05:16 AM

  2. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from new to wontfix

    This was modified in order to improve performance and reduce the number of instance variable assigns we need to do in cases with many renders inside a single view.

    February 24th, 2010 @ 07:46 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to

    October 15th, 2010 @ 11:01 PM