ruby - Rendering Layouts without loading its inner layout in Rails -


im trying bring layout in html page by

render layout 'flatty' 

thing loads whole flatty layout. in flatty.html.erb renders _header,_footer , _sidebar.html.erb dont want load _sidebar.html.erb in particular page. how should render this?

maybe in controller action, can have flag indicating sidebar should not rendered. then, in flatty.html.erb file, check flag variable before render _sidebar.html.erb.

for example, if have controller action called flatty, add instance variable, @disable_sidebar, act flag.

def flatty   @disable_sidebar = true   # other code   render layout: 'flatty' end 

then, in flatty.html.erb, add conditional before render sidebar (note ! negation in if statement:

<% if !@disable_sidebar %>   <%= render "layouts/sidebar" %> <% end %> 

alternatively, in flatty.html.erb can check controller , action values in params hash, , don't render sidebar if matches controller's action:

<% if params[:controller]!="your_controller" , !params[:action].eql? "flatty" %>   <%= render "layouts/sidebar" %> <% end %> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -