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 :

Finance <link

data-turbolinks-track=“true”
href="/assets/bootstrap/bootstrap.css?body=1
view-source:http://formidable-pup-77-133907.euw1.nitrousbox.com/assets/bootstrap/bootstrap.css?body=1"
media=“all” rel=“stylesheet” />

Liberator Admin Theme

How can this be happen ?

Roelof

On Thursday, August 7, 2014 7:48:21 PM UTC+1, Roelof W. wrote:

How can this be happen ?

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

On Friday, August 8, 2014 8:32:18 AM UTC+1, Roelof W. wrote:

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

Op vrijdag 8 augustus 2014 09:54:13 UTC+2 schreef Frederick C.:

end

  • 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

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">
 <div class="widget grid6">
  <div class="widget-header">
   <div class="widget-title">
    <i class="fa fa-comments"></i> Recent Comments
   </div>
   <div class="widget-controls">
    <div class="badge msg-badge">34</div>
   </div>
  </div> <!-- /widget-header -->
  <div class="comment">
   <div class="img-comment vignette">
            <%= image_tag "comment-1.jpg" %>
                        </div>
                        <div class="comment-body">
                            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 pixeden

routes.rb :

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

Op donderdag 7 augustus 2014 23:10:59 UTC+2 schreef Frederick C.: