# RJS templates, how to call a method from a specific controller?

**URL:** <https://www.ruby-forum.com/t/rjs-templates-how-to-call-a-method-from-a-specific-controller/144754>\
**Category:** Rails\
**Created:** [August 1, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/rjs-templates-how-to-call-a-method-from-a-specific-controller/144754 "2008-08-01T20:51:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lz-coelho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8c91f0/32.png) [@lz-coelho](https://www.ruby-forum.com/u/lz-coelho)\
**Post date:** [August 1, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/rjs-templates-how-to-call-a-method-from-a-specific-controller/144754/1 "2008-08-01T20:51:20Z")

</div>

Yeah,

I have User and Photo controllers and models.

the user has many photos  
photos belongs to the user

In a user profile section i have a photo gallery using RJS.

Well,

I’m on user controller, and the logic of ‘photos’ are on photos  
controller,  
how can i call the RJS template using logic from another controller (in  
this  
case photo)?

at user controller:  
jphoto.rjs  
page.replace\_html('html\_id, :partial =\> ‘photo’)

at photo.html.erb

here i need put a lot of logic from the photo controller, how can i  
use a  
method from it?

Thank your very much for the attention!

–  
Regards,

Luiz Vitor Martinez C.  
cel.: (11) 8187-8662  
blog: [rubz.org](http://rubz.org)  
engineer student at maua.br

---

<div class="post-metadata">

**Author:** ![lz-coelho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8c91f0/32.png) [@lz-coelho](https://www.ruby-forum.com/u/lz-coelho)\
**Post date:** [August 2, 2008, 12:18am UTC](https://www.ruby-forum.com/t/rjs-templates-how-to-call-a-method-from-a-specific-controller/144754/2 "2008-08-02T00:18:28Z")

</div>

Hey, maybe you’re looking for:

redirect\_to :controller =\> :controller-name, :action =\> :action-name
