Forum: Ruby on Rails Stylesheet Rendering Issues

8978da8848b68fbee6d6e2e12e59b316?d=identicon&s=25 Steven Natera (Guest)
on 2014-08-20 08:25
(Received via mailing list)
I have a landing page and chapter1 page. The landing view is linked to
one
stylesheet. The chapter1 view is linked to another stylesheet. When I go
to
the home page the correct CSS is applied but when I click to my next
page,
the CSS form the landing view is being applied to the chapter1 view.
When I
refresh the chapter1 view, the correct CSS is applied but then when I
click
back to the home page, the chapter1 CSS is being applied to the landing
view. I suspect my pages are rendering both stylesheets. How do I
prevent
this? How do I select which stylesheets are rendered for the views?

app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
  <title>OrgoDojo</title>
  <%= stylesheet_link_tag    'application', media: 'all',
'data-turbolinks-track' => true %>
  <%= yield(:head) %>
  <%= yield(:chapters) %>

  <%= javascript_include_tag 'application', 'data-turbolinks-track' =>
true
%>
  <%= csrf_meta_tags %>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<%= yield %>
<%= render 'layouts/footer_below' %>



</body>
</html>





app/views/pages/chapter1.html.erb
<% content_for(:chapters) do %>
    <%= stylesheet_link_tag 'chapters' , :media => "all" %>
<% end %>

<%= render 'pages/chapters_header' %>

<h1> This is chapter 1</h1>
<p> Hello Hello </p>



app/views/pages/home.html.erb
<% content_for(:head) do %>
    <%= stylesheet_link_tag 'custom' , :media => "all" %>
<% end %>

<%= render 'layouts/header' %>
<%= render 'layouts/welcome_section' %>
<%= render 'layouts/benefits_section' %>
<%= render 'layouts/footer_above' %>
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2014-08-21 05:54
(Received via mailing list)
On Tue, Aug 19, 2014 at 2:58 PM, Steven Natera <snatera@conncoll.edu>
wrote:

> I have a landing page and chapter1 page. The landing view is linked to one
> stylesheet. The chapter1 view is linked to another stylesheet. When I go to
> the home page the correct CSS is applied but when I click to my next page,
> the CSS form the landing view is being applied to the chapter1 view. When I
> refresh the chapter1 view, the correct CSS is applied but then when I click
> back to the home page, the chapter1 CSS is being applied to the landing
> view. I suspect my pages are rendering both stylesheets. How do I prevent
> this? How do I select which stylesheets are rendered for the views?
>

I'm guessing this is actually a turbolinks problem. When you go *back*
to
the home page, reload it in the browser and see if it gets displayed
correctly at that point.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.