# Rails3 view\_paths

**URL:** <https://www.ruby-forum.com/t/rails3-view-paths/192845>\
**Category:** Rails\
**Created:** [August 6, 2010, 8:29pm UTC](https://www.ruby-forum.com/t/rails3-view-paths/192845 "2010-08-06T20:29:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Romanov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6f9a4e/32.png) [@Andrew\_Romanov](https://www.ruby-forum.com/u/Andrew_Romanov)\
**Post date:** [August 6, 2010, 8:29pm UTC](https://www.ruby-forum.com/t/rails3-view-paths/192845/1 "2010-08-06T20:29:39Z")

</div>

Hello, I just want to check in the code if some template is present in  
views or not. In rails 2.3 I did this with following code -  
view\_paths.find\_template(template\_path, default\_template\_format). But  
in rails3 it doesn’t work and when I try to use view\_paths.find with  
some parameters, I get strange error:

NoMethodError Exception: You have a nil object when you didn’t expect  
it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.map

Can you help me with function to check if view exists in rails3?

---

<div class="post-metadata">

**Author:** ![Andrew\_Romanov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6f9a4e/32.png) [@Andrew\_Romanov](https://www.ruby-forum.com/u/Andrew_Romanov)\
**Post date:** [August 6, 2010, 8:47pm UTC](https://www.ruby-forum.com/t/rails3-view-paths/192845/2 "2010-08-06T20:47:48Z")

</div>

I had been checking through the view path code this past week – for a  
different reason: I don’t want any checking in the view paths at all.

I am still don’t have a clear picture of the entire dispatch stack,  
but as far as I can tell, the default responder attempts to render  
something, view\_paths gets checked, then it throws  
ActionView::MissingTemplate … api\_behavior (such as rendering json /  
xml) gets called as a result of rescuing from that exception. Assuming  
you are checking for the view within the dispatch and depending on  
what you want to do, you can handle the exception yourself (if it  
isn’t found) or extend the default responder.

Ho-Sheng H.

> **[lambda { }](http://ruby-lambda.blogspot.com)**
>
> lambda { put(self).in(:pipe).and.call() }
