Error application.html.erb

294 Views Asked by At

I just started rails today and it's very interesting. However, I've come across a problem. Whatever goes into application.html.erb should be seen in other webpages; such as the links, navbar. The problem is what I've put into application.htlm.erb is not showing in the other pages. If I put 2 links into application it won't show on the other webpages, the only way I could see the links is because I manually inserted the code into the individual webpage. I don't know if it's something wrong with application.html.erb itself, but I have 2 files in the layouts folder: application.html, and application.html.erb.

I'm also watching a video that goes along with my project, which means that I pretty much copied whatever the teacher was saying.

I really want to move on, but this problem is putting me back. If anyone can help please respond!

1

There are 1 best solutions below

0
goda On

There should only be application.html.erb in the layouts folder. The ERB extension is a rails filename extension that allows you to Embed Ruby code and PARTIALS.

application.html.erb is your master layout file, it renders partials and assembles the HTML structure in a modular way. It gets more apparent when your application grows!

Basically you are not supposed to edit application.html.erb directly unless you want to make a change to the existing HTML structure, which is basically

<html>
  <head>
  </head>
  <body>
  <%= yield %>
  </body>
</html>

If I were you, I would read the Rails Docs about layouts. It explains how pages get rendered and shows you where to place your logic (in this case your links).