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::Base @_render_stack is not being filled on edge

#1884

I'm the developer of Rails Footnotes plugin and I need to know the location of the template being rendered.

I've put a debugger at the end of process method on ActionController::Base, and then called:

@template.template

Which returned nil, Since the template method give me the last object in the @render_stack variable, I've checked and I can't actually see where the @render_stack is being filled. It's always empty.

Reported by José Valim · February 5th, 2009 @ 04:50 PM

State: wontfix
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. josh
    josh
    • State changed from new to wontfix

    Using @template always points the the current template being rendered. So after you return to the controller, no template is "currently" being render. It is only for use inside the template.

    February 5th, 2009 @ 09:35 PM

  2. José Valim
    José Valim

    So there is any way on Rails 2.3, without monkey patching, to know which template was rendered? I need its filename... :)

    February 5th, 2009 @ 09:38 PM

  3. josh
    josh

    We'll its hard to say "which template was rendered" since most templates rendered other nested templates. You probably don't want the "last" template cause that could be some partial, I guess your looking for the "first" rendered template, but that isn't directly known by AC.

    February 5th, 2009 @ 10:05 PM

  4. José Valim
    José Valim

    Makes sense! :) What I want was usually kept in @_first_render, but it's long gone right?

    February 5th, 2009 @ 10:07 PM

  5. josh
    josh

    Hrm, I was under the impression that was a testing only hack.

    Just curious why you need this. Then we should consider adding this as a public feature for controllers.

    February 5th, 2009 @ 10:11 PM

  6. José Valim
    José Valim

    I use it in Rails Footnotes plugin. It adds some links at the end of each view, which makes possible to open your controller or your view file in your editor (Textmate, for example) with just one click. It also adds some debug information, as queries, filters, etc.

    I was using the template in @_first_render to get the view filename to create the link.

    Screenshot here:

    http://1.bp.blogspot.com/_CVPxcH...

    Github here:

    http://github.com/josevalim/rail...

    February 5th, 2009 @ 10:30 PM