Render partial as full template

I would like to render a partial template as a full template. The reason
is that the partial contains content normally displayed via xhr and I
want to display it also if my app degrades.

The way I do this now is to have a full template containing one line
like
the below, but I’d rather do away with it because it seems a pointless
one line file:-
/app/views/my_controller/my_full_template.html.erb:
<%= render :partial => “my_partial_template” %>

I call this from the controller like this:
render :action => :my_full_template

What I’d like to do is render “my_partial_template” directly from the
controller but render it as a full template so that it is displayed
within my application layout.

The following is one solution but I think it isn’t very elegant
render :template => “my_controller/_my_partial_template)”

Is there a better way to achieve this?

Many thanks.

On 3 Apr 2008, at 20:48, John L. wrote:

What I’d like to do is render “my_partial_template” directly from the
controller but render it as a full template so that it is displayed
within my application layout.

The following is one solution but I think it isn’t very elegant
render :template => “my_controller/_my_partial_template)”

You can just call render :partial => ‘…’ in your controller.

Fred

Frederick C. wrote:

You can just call render :partial => ‘…’ in your controller.

Fred, hi. You can indeed do that but that renders JUST the partial, it
does not render the whole page layout like rendering a full template
does.

John L. wrote:

Frederick C. wrote:

You can just call render :partial => ‘…’ in your controller.

Fred, hi. You can indeed do that but that renders JUST the partial, it
does not render the whole page layout like rendering a full template
does.

render :partial => ‘…’, :layout => true

maybe?

Alex W. wrote:

render :partial => ‘…’, :layout => true

maybe?

Yes, that’s it! I wasn’t familiar with :layout => true.

Thanks Alex!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs