I see two times the head section when porting a html piece in erb

Hello,

I have this piece:

Liberator Admin Theme
<%= stylesheet_link_tag "bootstrap/bootstrap.css","font-awesome-4.0.3/css/font-awesome.min.css","jquery-ui.css","toastr.css","style.css" %>

When I look it in html it looks allright.

But when I display the above section with rails s I see this :

<!DOCTYPE html>
<html>
<head>
  <title>Finance</title>
  <link data-turbolinks-track="true" href="/assets/bootstrap/bootstrap.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/dashboard.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/font-awesome-4.0.3/css/font-awesome.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/font-awesome-4.0.3/css/font-awesome.min.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/jquery-ui.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/prism.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/style.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/toastr.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/yourname-custom.css?body=1" media="all" rel="stylesheet" />
<link data-turbolinks-track="true" href="/assets/application.css?body=1" media="all" rel="stylesheet" />
  <script data-turbolinks-track="true" src="/assets/jquery.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery_ujs.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/turbolinks.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/bootstrap.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/dashboard.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/excanvas.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery-1.10.2.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery-ui.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.easytabs.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.categories.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.crosshair.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.fillbetween.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.resize.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.flot.stack.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.hashchange.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/jquery.sparkline.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/prefixfree.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/prism.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/toastr.min.js?body=1"></script>
<script data-turbolinks-track="true" src="/assets/application.js?body=1"></script>
  <meta content="authenticity_token" name="csrf-param" />
<meta content="AneEAfp9UgCtaiugdo3Cp0dLHdP+e4i2cC/TPK6/G0s=" name="csrf-token" />
</head>
<body>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Liberator Admin Theme</title>

	<link rel="apple-touch-icon" sizes="144x144" href="apple-touch-icon-ipad-retina.png" />
	<link rel="apple-touch-icon" sizes="114x114" href="apple-touch-icon-iphone-retina.png" />
	<link rel="apple-touch-icon" sizes="72x72" href="apple-touch-icon-ipad.png" />
	<link rel="apple-touch-icon" sizes="57x57" href="apple-touch-icon-iphone.png" />
	<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />

	<!-- bootstrap -->

    <link href="/assets/bootstrap/bootstrap.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/font-awesome-4.0.3/css/font-awesome.min.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery-ui.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/toastr.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/style.css?body=1" media="screen" rel="stylesheet" />

</head>

How can this be happen ?

Roelof

You don’t say how you’re arriving at this result but it sounds like maybe you’re rendering with a layout when you didn’t intend to (render :layout => nil will suppress the layout)

Fred

I arrive at this result this way ?

Dashboard-controller.rb :

class DashboardController < ApplicationController
def show
end
end

show.html.erb

Liberator Admin Theme
<%= stylesheet_link_tag "bootstrap/bootstrap.css","font-awesome-4.0.3/css/font-awesome.min.css","jquery-ui.css","toastr.css","style.css" %>
<h1 class="page-title">Overzicht</h1>
Home Dashboard
<div class="fluid">
Recent Comments
34
<%= image_tag "comment-1.jpg" %>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod...
User: Kyle on IP: 172.10.56.3
Edit Approve Delete

<%= image_tag "comment-2.jpg" %>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod...
User: John on IP: 172.10.56.3
Edit Approve Delete

View All
    </div>
2013 © Liberator Admin v1.0. Powered by pixedenpixeden

routes.rb :

Rails.application.routes.draw do
get ‘dashboard/show’

root ‘dashboard#show’

end

That does sound like your problem then. By default whatever is in your show.erb file will be wrapped with what's in app/view/layouts/application.html.erb

You can either:
- not use the layout: either do render :layout => false in your action (or do layout false at the controller level
- remove the head section from show.html.erb and change application.html.erb to match (assuming that you want whatever is in the head of this page to be in the head of all pages)

Fred

Thanks,

I did not realize that when I do something in another view directory (app/views/dasboard) the layouts/application,html.erb is used.

So I can put most of it into that file and put the part between the body in show.html.erb.

Roelof