I'm developing a website using Ruby on Rails. Right now, I've added a bootstrap navigation bar in a partial file, "_navheader.html.erb" in my layouts folder. I render the partial right after the body tag in application.html.erb. The problem is that I have some CSS code for the nav bar in a separate css file. How do I link the CSS file, navheader.css.scss to the html file, _navheader.html.erb?
Add a comment
|
1 Answer
In your application.html.erb's head section, you can write
<% if content_for?(:head) %>
<%= yield(:head) %>
<% end %>
And in your _navheader.html.erb, you define your css file (with respective path) like this:
<% content_for :head do %>
<link rel="stylesheet" href="/assets/navheader.css.scss">
<% end %>
Hope it helps!
1 Comment
Dushyant
@user2771150 It is dynamic way of adding contents to your
<head> section from views.