# .rjs template doesn't load?

**URL:** <https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461>\
**Category:** Rails\
**Created:** [February 6, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461 "2006-02-06T19:07:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 7:07pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/1 "2006-02-06T19:07:39Z")

</div>

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 8:52pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/2 "2006-02-06T20:52:46Z")

</div>

Josh,

I have a similar requirement, but addressed it a little differently. I  
don’t know which is better. I set an instance variable in my  
controller called @error and fill it with a message if the action  
fails. Then in my .rjs I do:

if @error  
page.show ‘ajax-error’  
page.replace\_html ‘ajax-error’, @error  
else  
page.hide ‘ajax-error’  
page.replace\_html ‘my-div-name’, :partial =\> ‘mypartial’  
page.visual\_effect :highlight, ‘my-div-name’, :duration =\> 1.5  
end

-Tom

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/3 "2006-02-06T21:02:40Z")

</div>

Tom,

That would work well, problem is, I can’t make my action render  
_anything_ besides :text…

-Josh

* * *

Due to the recent increase in spam and falsely sent email, I now PGP  
Sign all of my outgoing mail to prove my identity. This means that  
you will see an attachment called “PGP.sig” with this message. This  
attachment can be used to prove that I am who I say I am. If you are  
not familiar with PGP, you can safely ignore it. For more  
information, please visit [http://www.pgp.com/](http://www.pgp.com/) or [http://www.gnupg.org/](http://www.gnupg.org/)

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 9:42pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/4 "2006-02-06T21:42:59Z")

</div>

I’m not sure how well RJS templates work with partials. I use Toms  
route myself and will have a complete rjs template for methods like  
create or update which would previously not have any.

Try making a create.rjs and have a flag in there like Tom suggested  
and see what happens. Skip the partial for now (at least on the xhr  
requests) to see if it helps.

-Nick

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/5 "2006-02-06T21:55:05Z")

</div>

Nick,

I might try that. But the issue is even worse. It doesn’t matter if  
it’s an RJS template. Even if it’s an RHTMl templaye, the code in the  
template just isn’t executed:

controller:

```
 if params[:commit] && @item.save
   if (request.xhr?)
     logger.debug "About to render"
     render(:partial => 'completechanges')

```

\_completechanges.rhtml:

test  
\<% logger.debug “This came from the partial” %\>

development.log:

…  
SQL (0.000150) COMMIT  
About to render

where is my “This came from the partial”?

-Josh

* * *

Due to the recent increase in spam and falsely sent email, I now PGP  
Sign all of my outgoing mail to prove my identity. This means that  
you will see an attachment called “PGP.sig” with this message. This  
attachment can be used to prove that I am who I say I am. If you are  
not familiar with PGP, you can safely ignore it. For more  
information, please visit [http://www.pgp.com/](http://www.pgp.com/) or [http://www.gnupg.org/](http://www.gnupg.org/)

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 6, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/6 "2006-02-06T22:07:20Z")

</div>

Ok. Scratch that. Part of the problem was bad file permissions! =o

I am still having trouble but will play around a little more.

## -Josh

Due to the recent increase in spam and falsely sent email, I now PGP  
Sign all of my outgoing mail to prove my identity. This means that  
you will see an attachment called “PGP.sig” with this message. This  
attachment can be used to prove that I am who I say I am. If you are  
not familiar with PGP, you can safely ignore it. For more  
information, please visit [http://www.pgp.com/](http://www.pgp.com/) or [http://www.gnupg.org/](http://www.gnupg.org/)

---

<div class="post-metadata">

**Author:** ![Joshua\_Gitlin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@Joshua\_Gitlin](https://www.ruby-forum.com/u/Joshua_Gitlin)\
**Post date:** [February 7, 2006, 4:24pm UTC](https://www.ruby-forum.com/t/rjs-template-doesnt-load/53461/7 "2006-02-07T16:24:06Z")

</div>

Josh,

Just a couple other quick notes.

- Make sure you don’t have an .rhtml template with the same name as it  
would obscure the .rjs template.

- If in your controller you might render different views depending on  
something, be sure to call it with a return, e.g.:

-Tom
