Partial

From knowledgebase
Jump to navigation Jump to search

A partial is a snippet of HTML and Ruby code that can be reused in multiple locations:

{{{

New post

<%= render 'form' %>

<%= link_to 'Back', posts_path %> }}}

The {{{<%= render 'form' %>}}} line is our first introduction to partials in Rails. A partial is a snippet of HTML and Ruby code that can be reused in multiple locations. In this case, the form used to make a new post is basically identical to the form used to edit a post, both having text fields for the name and title, a text area for the content, and a button to create the new post or to update the existing one.

Source: http://guides.rubyonrails.org/getting_started.html