Topic: rendering normal action as a partial

I need to render an action, get the content as a string and display it somewhere on my page.
but this action is also called normally, so the view file is name list.rxml not _list.rxml

can I call this as a partial anyway?

Re: rendering normal action as a partial

Not sure I know what you mean here but the short answer is no: partials need to start like _this, otherwise they are considered an action.

Re: rendering normal action as a partial

anyone have a 'yes' answer (i.e.: a solution?)

other than a symlink.

Re: rendering normal action as a partial

actually, If I could use something like

content = render :action => {:controller => 'foo', :action => 'bar'}, :as_string => true

that would be awesome

Last edited by somekool (2007-01-27 03:06:35)

Re: rendering normal action as a partial

Check out render_to_string

Railscasts - Free Ruby on Rails Screencasts

Re: rendering normal action as a partial

thanks....

but I have a problem

I am in FooController

I do

render_to_string {:controller => 'bar', :action => 'index'}

and I get the following error

Template is missing

Missing template /path/to/www/docs/../config/../app/views/foo/index.rhtml


while it should search into .../bar/... subdirectory.

any idea why ?

Re: rendering normal action as a partial

I did

render_to_string {:action => '../bar/all'}

it fetches the right view, but does not call the controller code in BarController#all

I'm not sure what to do?

Re: rendering normal action as a partial

The "render" action does not call controller code. What you are trying to do isn't exactly possible in Rails, but there are workaround. See this post and the following replies for some information on the topic.

Railscasts - Free Ruby on Rails Screencasts

Re: rendering normal action as a partial

very said it ain't possible.
but very interesting reading you sent me to. thanks.

I'll opt for the simple approach and give up a little bit on my requirement.

thanks again.

Re: rendering normal action as a partial

s/very said/very SAD/