Question

I am rendering different layouts for each controller like so:

# layouts/student.html.erb:
<% content_for :stylesheets do %>
  #menu_container {background-color: #3085BD;}
<% end %>
<% content_for :side_menu do %>
  <h4 style="text-align: center;"> STUDENTS</h4>
<% end %>
<%= render :template => 'layouts/application' %>

Using turbolinks, I've found that the layout is not changing when I navigate between different parts of the site. A page refresh fixes everything.

Is there a way to tell turbolinks to grab the layout along with the page content?

Was it helpful?

Solution

I finally got this to work by placing the following lines within the body tag of application.html.erb:

<%= content_for?(:side_menu) ? yield(:side_menu) : yield %>
<style type="text/css">
 <%= content_for?(:stylesheets) ? yield(:stylesheets) : yield %>
</style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top