An event that stumbled while making an original app on rails.
The part surrounded by the red frame
below was called as a partial template.
The top page has the following structure, and I don't want to call the header, so I was wondering what to do.
Since I want to display all headers other than the top page, I render the partial template with ʻapplication.html.erb`.
erb:application.html.erb
<!DOCTYPE html>
<html>
<head>~abridgement~</head>
<body>
<%= render "shared/header" %> <%#I'm calling the header here.
<%= yield %>
<%= render "shared/footer" %>
</body>
</html>
This article If the current page is not the top page (root_path)
, I tried not to call the partial template.
erb:application.html.erb
<body>
<% unless current_page?(root_path) %> <%#If the current page is root with unless, do not call
<%= render "shared/header" %>
<% end %>
<%= yield %>
<%= render "shared/footer" %>
</body>
When specifying the page to call the partial template, listed on the controller Fire a page called by JavaScript, there seems to be various means In my case, only one page is hidden, so I thought this method would be better.
If you have any reason why this method is not recommended, please let us know.
Recommended Posts