# Can't find the partial

**URL:** <https://www.ruby-forum.com/t/cant-find-the-partial/132222>\
**Category:** Rails\
**Created:** [March 18, 2008, 1:08am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222 "2008-03-18T01:08:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 18, 2008, 1:08am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222/1 "2008-03-18T01:08:13Z")

</div>

I have a simple ajax request that should return a partial, but for some  
reason I am continually told that it is not there. I have modified the  
partial location to other partials that do work fine elsewhere and it  
still tells me that it can’t find those files.

# Here is the code:

class Admin::ContentPhotosController \< ApplicationController  
…  
def new  
respond\_to do |format|  
format.js { render :partial =\> “admin/content\_photos/form” }  
end  
end  
…  
end

# Here is some console output showing that the file exists

$ ls app/views/admin/content\_photos/  
\_form.html.haml index.html.haml new.html.haml

# Here is the error message if when I access [http://localhost:3000/admin/content\_photos/new.js](http://localhost:3000/admin/content_photos/new.js)

Couldn’t find template file for admin/content\_photos/\_form

Help is appreciated.

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 18, 2008, 2:43am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222/2 "2008-03-18T02:43:25Z")

</div>

iso … wrote:

> # Here is the code:
> 
> class Admin::ContentPhotosController \< ApplicationController  
> …  
> def new  
> respond\_to do |format|  
> format.js { render :partial =\> “admin/content\_photos/form” }  
> end  
> end  
> …  
> end

format.js { render :partial =\> “form” }

hth

ilan

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 18, 2008, 2:54am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222/3 "2008-03-18T02:54:31Z")

</div>

Ilan B. wrote:

> iso … wrote:
> 
> > # Here is the code:
> > 
> > class Admin::ContentPhotosController \< ApplicationController  
> > …  
> > def new  
> > respond\_to do |format|  
> > format.js { render :partial =\> “admin/content\_photos/form” }  
> > end  
> > end  
> > …  
> > end
> 
> format.js { render :partial =\> “form” }
> 
> hth
> 
> ilan

## Unfortunately, that doesn’t seem to work either. I get the same error message:

## ActionView::ActionViewError (Couldn’t find template file for admin/content\_photos/\_form in ["/Users/chris/Documents/Projects/Rails/cms/app/views"]):

I wasn’t aware that you could render the partials using that path, so  
thanks for that 🙂

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 18, 2008, 4:33am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222/4 "2008-03-18T04:33:52Z")

</div>

David A. Black wrote:

> Hi –
> 
> On Tue, 18 Mar 2008, iso … wrote:
> 
> > > > ```
> > > > format.js { render :partial => "admin/content_photos/form" }
> > > > 
> > > > ```
> > > 
> > > ilan
> > 
> > Unfortunately, that doesn’t seem to work either. I get the same error  
> > message:
> 
> Try calling your partial \_form.js.haml.
> 
> David

I didn’t want to call it \_form.js.haml since it is rendered on a normal  
http request, but renaming it to \_form.haml did the trick, which makes  
perfect sense.

Thanks David.

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 18, 2008, 3:53am UTC](https://www.ruby-forum.com/t/cant-find-the-partial/132222/5 "2008-03-18T03:53:06Z")

</div>

Hi –

On Tue, 18 Mar 2008, iso … wrote:

> > > ```
> > > format.js { render :partial => "admin/content_photos/form" }
> > > 
> > > ```
> > 
> > ilan
> 
> Unfortunately, that doesn’t seem to work either. I get the same error  
> message:

Try calling your partial \_form.js.haml.

David

–  
Upcoming Rails training from David A. Black and Ruby Power and Light:  
ADVANCING WITH RAILS, April 14-17 2008, New York City  
CORE RAILS, June 24-27 2008, London (Skills Matter)  
See [http://www.rubypal.com](http://www.rubypal.com) for details. Berlin dates coming soon!
