Skip to content

Instantly share code, notes, and snippets.

@Mizpah
Created March 6, 2013 05:04
Show Gist options
  • Save Mizpah/5096859 to your computer and use it in GitHub Desktop.
Save Mizpah/5096859 to your computer and use it in GitHub Desktop.
I am trying to dynamically change the output of <%= render 'layouts/header %> called from application.html.erb, based on the controller. I have just created a namespaced admin controller, accessible under /admin The controller is Admin::DashboardController. Based on inheritance, I have to place my alternate version of the partial _header.html.er…
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= stylesheet_link_tag "application", media:" all" %>
<%= javascript_include_tag "application" %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "mmofish" %>">
<%= csrf_meta_tags %>
<%= render 'layouts/shim' %>
</head>
<body class="<%= controller_name %> <%= action_name %>">
<!-- header -->
<%= render 'layouts/header' %>
<div id="main" role="main">
<div class="container">
<div class="content">
<div class="row">
<div class="span12">
<%= render 'layouts/messages' %>
<!-- content -->
<%= yield %>
</div>
</div>
</div><!--! end of .content -->
</div> <!--! end of .container -->
<%= render 'layouts/footer' %>
</div> <!--! end of #main -->
</body>
</html>
#layouts/admin/_header.html.erb
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar_inner">
<div class="container">
<p>TESTING</p>
</nav>
</div>
</div>
</header>
<header class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar_inner">
<div class="container">
<%#= link_to "mmofish", root_path, id: "logo" %>
<%= link_to "mmofish", root_path, :class => 'brand', :id => 'logo' %>
<nav>
<%= render 'layouts/navigation' %>
<%#= link_to "Sign in", signup_path %></li> %>
</nav>
</div>
</div>
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment