Who is causing a partial to be rendered?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Who is causing a partial to be rendered?

Ralph Shnelvar
Is the a convenient programatic way for a partial to know what view (controller?) is causing it to be rendered?

For debugging purposes I want the partial to render the name of the view causing the partial to be rendered..

Ralph

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e1777685-61f0-4b40-acd9-48141bb2eb35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Who is causing a partial to be rendered?

Greg Navis
I think rack-mini-profiler should fit the bill. It shows the queries you executed and layouts you rendered.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAA6WWt-zJGO3vzqTrW%2Bgm5wSEKp2yka3daXku3FQBf06wc4guQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Who is causing a partial to be rendered?

Phil Edelbrock
In reply to this post by Ralph Shnelvar

> On Jul 26, 2017, at 8:58 PM, Ralph Shnelvar <[hidden email]> wrote:
>
> Is the a convenient programatic way for a partial to know what view (controller?) is causing it to be rendered?
>
> For debugging purposes I want the partial to render the name of the view causing the partial to be rendered..
>
> Ralph


I've done stuff stuff like this to pass in, to say, a mailer view to know how it is being called.  Some variation of that might work for you:

@mailer_name = caller_locations(1,1)[0].label

Hope that helps.


Phil

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E97512B7-C3C2-466F-BD88-ED860C63B3E1%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Who is causing a partial to be rendered?

Ralph Shnelvar
This is close to what I want, I think.

Where does the "@mailer_name = caller_locations(1,1)[0].label " go?  In a controller?  In a view?

What I really want is to not have to modify the source modules that are invoking the rendering but, instead, have the _header.html.erb source module dynamically say "I got invoked by root.html.erb".

Things get a bit more dicey, I think, if the sequence is
  root.html.erb
  appllication.html.erb     (authomagically invoked)
  root.html.erb

Thoughts?
 



On Thursday, July 27, 2017 at 12:23:37 AM UTC-6, Phil wrote:

> On Jul 26, 2017, at 8:58 PM, Ralph Shnelvar <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="B_KcNn2cAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ral...@...> wrote:
>
> Is the a convenient programatic way for a partial to know what view (controller?) is causing it to be rendered?
>
> For debugging purposes I want the partial to render the name of the view causing the partial to be rendered..
>
> Ralph


I've done stuff stuff like this to pass in, to say, a mailer view to know how it is being called.  Some variation of that might work for you:

@mailer_name = caller_locations(1,1)[0].label

Hope that helps.


Phil

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f5292800-17ef-499f-8be8-e6b34cb2fab8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...