views:

43

answers:

2

When try I following code in a controller, the view renders without using the layout

  def xyz
    render :partial => 'platinum_home', :layout => 'platinum_layout'
  end

But If I do the following inside the partial

<% render(:layout => "platinum_layout") do %>
  blah blah blah
<% end %>

It works just fine, is the first example not possible using rails?

+2  A: 

In your controller at the top add the following:

class SomeController < ApplicationController
    layout "platinum_layout", :only => :xyz
Sam
+1  A: 

Partial rendering in a controller is most commonly used together with Ajax calls that only update one or a few elements on a page without reloading. Rendering of partials from the controller makes it possible to use the same partial template in both the full-page rendering (by calling it from within the template) and when sub-page updates happen (from the controller action responding to Ajax calls). By default, the current layout is not used.

So to use current layout for your just used.

  def xyz
    render :partial => 'platinum_home', :layout => true
  end
Salil