# Something strange about RJS, please help

**URL:** <https://www.ruby-forum.com/t/something-strange-about-rjs-please-help/153051>\
**Category:** Rails\
**Created:** [November 11, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/something-strange-about-rjs-please-help/153051 "2008-11-11T15:34:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![msmsms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@msmsms](https://www.ruby-forum.com/u/msmsms)\
**Post date:** [November 11, 2008, 3:34pm UTC](https://www.ruby-forum.com/t/something-strange-about-rjs-please-help/153051/1 "2008-11-11T15:34:32Z")

</div>

Hello,

thanks for reading this. 🙂 I’ve got some problems with RJS in  
separate files. What’s the correct extension? When I name it \*.rjs /  
\*.js.rjs, Ruby on Rails complains that it in not able to find a  
\*.js.erb template. But when I name it \*.js.erb, nothing is translated  
to javascript, only the raw text is given back to the client. When I  
try inline RJS directly in my controllers with “render :update …”,  
it runs perfectly. What am I doing wrong?

Really thank you for any answers.  
ms

---

<div class="post-metadata">

**Author:** ![msmsms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@msmsms](https://www.ruby-forum.com/u/msmsms)\
**Post date:** [November 11, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/something-strange-about-rjs-please-help/153051/2 "2008-11-11T15:53:54Z")

</div>

The right naming is \*.js.rjs

At the end of the controller you need:

respond\_to do |format|  
format.js  
end

to make that work

---

<div class="post-metadata">

**Author:** ![msmsms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@msmsms](https://www.ruby-forum.com/u/msmsms)\
**Post date:** [November 11, 2008, 4:56pm UTC](https://www.ruby-forum.com/t/something-strange-about-rjs-please-help/153051/3 "2008-11-11T16:56:43Z")

</div>

On Nov 11, 9:49 am, Thorsten Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The right naming is \*.js.rjs
> 
> At the end of the controller you need:
> 
> respond\_to do |format|  
> format.js  
> end
> 
> to make that work

Keep this bug report in mind if you’re calling #render\_to\_string  
before the default view is rendered:  
[http://rails.lighthouseapp.com/projects/8994/tickets/870-js-rjs-views-no-longer-found-after-render\_to\_string-call](http://rails.lighthouseapp.com/projects/8994/tickets/870-js-rjs-views-no-longer-found-after-render_to_string-call)

The solution is to rename the default view to filename.rjs (as opposed  
to filename.js.rjs).

Cheers,  
Nick
