# Can I render a page using a template of another controller

**URL:** <https://www.ruby-forum.com/t/can-i-render-a-page-using-a-template-of-another-controller/121995>\
**Category:** Rails\
**Created:** [December 3, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/can-i-render-a-page-using-a-template-of-another-controller/121995 "2007-12-03T19:04:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [December 3, 2007, 7:04pm UTC](https://www.ruby-forum.com/t/can-i-render-a-page-using-a-template-of-another-controller/121995/1 "2007-12-03T19:04:53Z")

</div>

Hi,

I think it should be simple but not working for me.

class OneController \< ApplicationController

def first  
render :controller =\> ‘two’, :action =\> ‘first’  
end

end

I want it to render using “/two/first.html.erb” but it still uses  
“/one/first.html.erb”.  
Is :controller key not acceptable?

Actually, I’m practicing restful resources.  
Models are like this: Message has many comments.  
I want new comment form to be in the message/show page instead of being  
separated on its own.  
If the comment is not validated in create action, it’s supposed to  
render message/show.  
But it didn’t work as I expected.

Is it not allowed? If so, what’s the usual solution?

Thanks.

Sam

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [December 3, 2007, 7:36pm UTC](https://www.ruby-forum.com/t/can-i-render-a-page-using-a-template-of-another-controller/121995/2 "2007-12-03T19:36:48Z")

</div>

Hi,

Thorsten M. wrote:

> render :template =\> “two/first.html.erb”  
> works for me, maybe give it a try

:template works in rails 1.2.x.  
However, in rails edge, it’s always relative path whether I put a  
leading “/” or not.  
So I had to put “…/” in front.

Anyway, it works.  
Thank you very much.

Sam

---

<div class="post-metadata">

**Author:** ![ssk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@ssk](https://www.ruby-forum.com/u/ssk)\
**Post date:** [December 3, 2007, 7:18pm UTC](https://www.ruby-forum.com/t/can-i-render-a-page-using-a-template-of-another-controller/121995/3 "2007-12-03T19:18:45Z")

</div>

render :template =\> “two/first.html.erb”  
works for me, maybe give it a try
