# Failing to render RJS

**URL:** <https://www.ruby-forum.com/t/failing-to-render-rjs/156507>\
**Category:** Rails\
**Created:** [December 29, 2008, 9:42am UTC](https://www.ruby-forum.com/t/failing-to-render-rjs/156507 "2008-12-29T09:42:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [December 29, 2008, 9:42am UTC](https://www.ruby-forum.com/t/failing-to-render-rjs/156507/1 "2008-12-29T09:42:02Z")

</div>

My code looks like the following, but for some reason the rjs template  
(index.js.erb) is not being rendered. I’ve also tried naming the rjs  
file index.js.rjs with no luck.

home\_controller.rb:

def index  
respond\_to do |format|  
format.js  
format.html  
end  
end

index.js.erb:

page \<\< “var data = ‘Core  
Selectors,Attributes,Traversing,Manipulation’.split(’,’);”  
page \<\< “$(’#example’).autocomplete(data);”

How does rails decide when to render an rjs file in addition to an html  
file?

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [December 29, 2008, 10:29am UTC](https://www.ruby-forum.com/t/failing-to-render-rjs/156507/2 "2008-12-29T10:29:18Z")

</div>

On 29 Dec 2008, at 08:42, Adam T. wrote:

> My code looks like the following, but for some reason the rjs template  
> (index.js.erb) is not being rendered. I’ve also tried naming the rjs  
> file index.js.rjs with no luck.

What does the thing making the request look like ?(index.js.erb will  
never work, since it will just try and pass that file through erb even  
though that file isn’t an erb template at all)

Fred

---

<div class="post-metadata">

**Author:** ![toro04](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ea5d25/32.png) [@toro04](https://www.ruby-forum.com/u/toro04)\
**Post date:** [December 29, 2008, 1:59pm UTC](https://www.ruby-forum.com/t/failing-to-render-rjs/156507/3 "2008-12-29T13:59:26Z")

</div>

You need to rename it to index.js.rjs. Check in firebug then if you  
get response.
