Newbie here. I placed a debugger statement into a view and I then executed a where command hoping to find which controller caused the view to be rendered. The stack is interesting but does not seem to give me the info I ned. Is there a way to find out what caused the view to be rendered? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
By default, views are tied to controllers. So the views in app/views/ c1s are invoked by the app/views/c1s_controller. However, it is possible to render views from an arbitrary controller. grep render app/controllers/*. Partials might be called from helpers or other views. On Dec 31, 6:08 am, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Newbie here. > > I placed a debugger statement into a view and I then executed a > where > command hoping to find which controller caused the view to be rendered. > > The stack is interesting but does not seem to give me the info I ned. > > Is there a way to find out what caused the view to be rendered? > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Student Jr wrote:> By default, views are tied to controllers. So the views in app/views/ > c1s are invoked by the app/views/c1s_controller. > > However, it is possible to render views from an arbitrary controller. > grep render app/controllers/*. Partials might be called from helpers > or other views.Yes, but a controller can generate several views. Is there a way to get to the line of code in the controller that generates the view and/or partial. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Different question, different answer. There are rules. Of course, an explicit call via render comes first. If there is no render, then the view with the same name as the action is rendered. Which is why a stack trace is not sufficient. On Dec 31, 8:41 am, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Student Jr wrote: > > By default, views are tied to controllers. So the views in app/views/ > > c1s are invoked by the app/views/c1s_controller. > > > However, it is possible to render views from an arbitrary controller. > > grep render app/controllers/*. Partials might be called from helpers > > or other views. > > Yes, but a controller can generate several views. Is there a way to get > to the line of code in the controller that generates the view and/or > partial. > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Student Jr wrote:> Different question, different answer. > > There are rules. Of course, an explicit call via render comes first. > If there is no render, then the view with the same name as the action > is rendered. > Which is why a stack trace is not sufficient. >Are you saying that if the view is rendered via an explicit render that it will be on the stack trace? (Sorry, not at a computer where I''m running rails but I''d like to have the answer so I can think about it.) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I believe so. On Dec 31, 9:17 am, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Student Jr wrote: > > Different question, different answer. > > > There are rules. Of course, an explicit call via render comes first. > > If there is no render, then the view with the same name as the action > > is rendered. > > Which is why a stack trace is not sufficient. > > Are you saying that if the view is rendered via an explicit render that > it will be on the stack trace? (Sorry, not at a computer where I''m > running rails but I''d like to have the answer so I can think about it.) > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ralph Shnelvar wrote:> Newbie here. > > I placed a debugger statement into a view and I then executed a > where > command hoping to find which controller caused the view to be rendered. > > The stack is interesting but does not seem to give me the info I ned. > > Is there a way to find out what caused the view to be rendered?Look at params[:controller] and params[:action]. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.