# Really Simple RJS question

**URL:** <https://www.ruby-forum.com/t/really-simple-rjs-question/132032>\
**Category:** Rails\
**Created:** [March 15, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/really-simple-rjs-question/132032 "2008-03-15T17:13:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [March 15, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/really-simple-rjs-question/132032/1 "2008-03-15T17:13:28Z")

</div>

I have a really simple RJS question.

Lets say I have a controller with the action create. I want to handle  
the action in a rjs template so I have something like…

def create

respond\_to do |format|  
…  
format.js  
end  
end

Now i know an ajax call will result in the program looking for a  
create.rjs template to call. The problem is what if I have another  
controller with a create action that I also want to use a template with?  
Then I would have two different RJS templates called create. Is there a  
way to change the default name of the template and instruct the action  
to call it. Something like:

format.js =\> ‘my.rjs’

Thanks,  
steve

---

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [March 15, 2008, 5:21pm UTC](https://www.ruby-forum.com/t/really-simple-rjs-question/132032/2 "2008-03-15T17:21:22Z")

</div>

Yes, off the top of my head it’s:

format.js { render :template =\> ‘some\_dir\_in\_views/my.rjs’ }

Read the docs on render():  
[http://api.rubyonrails.com/classes/ActionController/Base.html#M000452](http://api.rubyonrails.com/classes/ActionController/Base.html#M000452)

On Mar 15, 12:13 pm, Steve G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sjglazer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ee59a6/32.png) [@sjglazer](https://www.ruby-forum.com/u/sjglazer)\
**Post date:** [March 15, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/really-simple-rjs-question/132032/3 "2008-03-15T17:22:22Z")

</div>

Thanks Jeff I will have a look!

Jeff Emminger wrote:

> Yes, off the top of my head it’s:
> 
> format.js { render :template =\> ‘some\_dir\_in\_views/my.rjs’ }
> 
> Read the docs on render():  
> [Peak Obsession](http://api.rubyonrails.com/classes/ActionController/Base.html#M000452)
> 
> On Mar 15, 12:13 pm, Steve G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
