If you want to keep your code simple and/or reuse a block of code in multiple files, then you can store that code in an html.erb file called a partial.
Create partial 🧩
- Go to app > views.
- Create a folder called shared.
- Create a file to store your code in and name it using the syntax: _[partial].html.erb Insert partial ⬇️
In the file where you want to include the code from a partial, insert the tag
<%= render partial "shared/
[partial]
%>
View page 👀
You’ll see your page with the code from the partial included.