# RJS file not rendering

**URL:** <https://www.ruby-forum.com/t/rjs-file-not-rendering/175915>\
**Category:** Rails\
**Created:** [September 22, 2009, 8:00pm UTC](https://www.ruby-forum.com/t/rjs-file-not-rendering/175915 "2009-09-22T20:00:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronvb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@aaronvb](https://www.ruby-forum.com/u/aaronvb)\
**Post date:** [September 22, 2009, 8:00pm UTC](https://www.ruby-forum.com/t/rjs-file-not-rendering/175915/1 "2009-09-22T20:00:55Z")

</div>

Hi there,  
I’ve done this before many times. But for some reason, my controller  
isn’t rendering my RJS file. Here’s the setup:

In the View:

- a call to remote\_function:

```auto
<select name="state" onchange="<%=
remote_function(:url=>{:action=>:cities})%>">
```

In the Controller:

- get the data that I need:

```auto
def cities
  @cities = Store.find_by_sql("select DISTINCT city from stores where
state='#{params[:state]}'")
end
```

I have a file called cities.rjs. However, when I run it, I get the  
following error:

```auto
ActionView::MissingTemplate (Missing template stores/cities.erb in view
path app/views:vendor/plugins/easy-fckeditor/app/views):
```

I’ve tried creating a file called cities.erb, but that doesn’t work  
either. The path is correct: I have the /views/stores folder there and  
the file is where it’s supposedly looking. I can’t fathom what the issue  
is here. Any help?

Thanks,  
Aaron.

---

<div class="post-metadata">

**Author:** ![aaronvb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@aaronvb](https://www.ruby-forum.com/u/aaronvb)\
**Post date:** [September 23, 2009, 12:36am UTC](https://www.ruby-forum.com/t/rjs-file-not-rendering/175915/2 "2009-09-23T00:36:52Z")

</div>

Hi Aaron,  
On Tue, 2009-09-22 at 20:00 +0200, Aaron V. wrote:

I think you need to tell Rails what view template to use.

> def cities  
> respond\_to do |format|  
> format.js { @cities = Store.find\_by … }  
> end  
> end

Pretty sure this will pick up the .rjs template.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![aaronvb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@aaronvb](https://www.ruby-forum.com/u/aaronvb)\
**Post date:** [September 23, 2009, 5:14pm UTC](https://www.ruby-forum.com/t/rjs-file-not-rendering/175915/3 "2009-09-23T17:14:08Z")

</div>

Try renaming cities.rjs to cities.js.rjs. Rails is smart enough to know  
that it’s getting a JS request, so there’s no need to tell Rails to what  
template to use as long as the controller method and view template  
follow  
the standard naming convention.  
Tim

On Tue, Sep 22, 2009 at 5:36 PM, bill walton [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > end
> 
> Pretty sure this will pick up the .rjs template.
> 
> HTH,  
> Bill
> 
> >

–  
Tim L.  
Coroutine LLC  
516 Tennessee St., Suite 215  
Memphis, TN 38103  
office: 901.312.8818  
mobile: 901.490.5325  
[http://www.coroutine.com](http://www.coroutine.com)

---

<div class="post-metadata">

**Author:** ![aaronvb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/94ad74/32.png) [@aaronvb](https://www.ruby-forum.com/u/aaronvb)\
**Post date:** [September 23, 2009, 5:31pm UTC](https://www.ruby-forum.com/t/rjs-file-not-rendering/175915/4 "2009-09-23T17:31:05Z")

</div>

Hi again,  
Bah, turns out I had the right files in the wrong folder. I have an  
admin/stores folder and a plain old stores folder, and my partials and  
RJS were in the admin version Stupid!

Thanks,  
Aaron.
