# Who caused the view to be rendered

**URL:** <https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913>\
**Category:** Rails\
**Created:** [December 31, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913 "2009-12-31T13:08:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/1 "2009-12-31T13:08:58Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 2:58pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/2 "2009-12-31T14:58:53Z")

</div>

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 S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 3:41pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/3 "2009-12-31T15:41:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 4:17pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/4 "2009-12-31T16:17:33Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 4:03pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/5 "2009-12-31T16:03:51Z")

</div>

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 S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## 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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 7:06pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/6 "2009-12-31T19:06:10Z")

</div>

Ralph S. 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](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [December 31, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/who-caused-the-view-to-be-rendered/180913/7 "2009-12-31T16:41:19Z")

</div>

I believe so.

On Dec 31, 9:17 am, Ralph S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## 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 removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
