How to render controller x partial from controller y?

seems like this should be easy, but it is evading me…

Assume:

http://myserver/controller-x/action-x

In app/views/controller-x/action-x.rhtml I have:

<%= render(:partial => ‘partial-x’) %>

And this will render:

app/views/controller-x/_partial-x.rhtml

Now - I want to render _partial-x.rhtml from a different controller. The
only way I’ve been able to make this work is to copy _partial-x.rhtml
into the views folder for the other controller, but that’s not very
Railsy or DRY.

Is it possible for me to render a particular partial from several
different controllers without duplicating the partial?

Thanks.

Cayce B. wrote:

Now - I want to render _partial-x.rhtml from a different controller. The
only way I’ve been able to make this work is to copy _partial-x.rhtml
into the views folder for the other controller, but that’s not very
Railsy or DRY.

Thanks.

i would try this, say the view folder is called posts:

           <%= render(:partial => '/posts/partial-x') %>

that should work.

Oh man - so easy.

Really appreciate it, J.

c.

Jonny wrote:

Cayce B. wrote:

Now - I want to render _partial-x.rhtml from a different controller. The
only way I’ve been able to make this work is to copy _partial-x.rhtml
into the views folder for the other controller, but that’s not very
Railsy or DRY.

Thanks.

i would try this, say the view folder is called posts:

           <%= render(:partial => '/posts/partial-x') %>

that should work.