This time I would like to share how to write a common layout in a rails html file in one file. I think there is a file called application.html.erb under viwes / layout. You can avoid writing the same code by putting together the common layout parts in that file as shown below.
<!DOCTYPE html>
<html>
  <head>
    <title>Tweet</title>
    <%= csrf_meta_tags %>
    <%= csp_meta_tag %>
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
  </head>
  <body>
  <header>
  <div class="header-logo">
    <%= link_to("TweetApp","/") %>
  </div>
  <ul class="header-menus">
  <li>
    <%= link_to("What is TweetApp","/about") %>
  </li>
  <li>
  <%= link_to("Post list","/posts/index") %>
  </li>
  </ul>
</header>
    <%= yield %>
  </body>
</html>
The content of the above
Recommended Posts