Wednesday 8 February 2012

Blocking default design present in application layout


This is the way from where you are calling your default sidebar in application.html.erb


<div id="define_according_to_your_stylesheet" class="<%= sidebar_disabled? %>">
<!-- START Sidebar -->
                 <%= yield :sidebar %>
                 <%= app_screen_tip -%>
<!-- END Sidebar -->
     </div>

Here <%=sidebar_disabled? %> is calling method present in application helper


define a method in application helper which is loaded automatically when your application loaded


def sidebar_disabled?
    current_page = "#{controller.controller_name}.#{controller.action_name}"
    current_controller = controller.controller_name
    pages = %w(
      home.index
#comment [home(its your controller name).index(its your action)]
   
)    return pages.include?(current_controller) || pages.include?(current_page)
  end



by this way you can block anything which loaded by default when application loaded



No comments:

Post a Comment