DEV Community

ycorredius
ycorredius

Posted on

Partial Forms on Rails

Hello to all who are reading this. I would like to say thank you for taking the time checking out this quick lesson on partials in Ruby on Rails.

Partial forms in rails are a quick way to reduce redundant forms or pages on you website, a simple example is the ability create, edit, and update a new record. Since most of the information it is simple to create a form with labels and textarea fields of the the different model attributes. To create a partial you simply create a file in the same class view folder with the name for your choosing prefixed with and underscore(_).

_page.htmle.erb

To use this on another page use the helper method render followed by the name for page in quotes without the underscore(_).

<%= render 'page'%>

This simple and effective tool allows you to create simplistic and more readable code without any extra stress.

Top comments (0)