One of the founding principles of Ruby on Rails is “Don’t Repeat Yourself”, or DRY. There are many reasons to follow this principle, not the least of which is if you change one instance of repetition, you change the other. One way to insure this in your views is to use partials.
<%= render form %>
This would render a file in the current directory called ”_form.html.erb”. This is useful because you can use the same view for your new form as well as your edit form. But wait, there’s more. Partials aren’t just limited to forms, you can refactor anything, just have it’s name start with an underscore and call it with the render method in your view. You can then render another partial in your partial so you can have a partial inside of your partial.
<%= render "errors", object: form.object %> <div> <%= form.label :name %>
<%= form.text_field :name %>