From ccbd32c294bf685a389d456164a12fd777756873 Mon Sep 17 00:00:00 2001
From: Oscar Del Ben <info@oscardelben.com>
Date: Wed, 25 Apr 2012 13:18:59 +0200
Subject: Add partials explanation to getting started guide

---
 guides/source/getting_started.textile | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

(limited to 'guides/source/getting_started.textile')

diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile
index 78e9761570..88d5ce6d9b 100644
--- a/guides/source/getting_started.textile
+++ b/guides/source/getting_started.textile
@@ -899,6 +899,37 @@ And here's how our app looks so far:
 !images/getting_started/index_action_with_edit_link.png(Index action
 with edit link)!
 
+h4. Using partials to clean up duplication in views
+
++partials+ are what Rails uses to remove duplication in views. Here's a
+simple example:
+
+<erb>
+# app/views/user/show.html.erb
+
+<h1><%= @user.name %></h1>
+
+<%= render 'user_details' %>
+
+# app/views/user/_user_details.html.erb
+
+<%= @user.location %>
+
+<%= @user.about_me %>
+</erb>
+
+The +show+ view will automatically include the content of the
++_user_details+ view. Note that partials are prefixed by an underscore,
+as to not be confused with regular views. However, you don't include the
+underscore when including them with the +helper+ method.
+
+TIP: You can red more about partials in the "Layouts and Rendering in
+Rails":layouts_and_rendering.html guide.
+
+Our +edit+ action looks very similar to the +new+ action, in fact they
+both share the same code for displaying the form. Lets clean them up by
+using a +_form+ partial.
+
 h4. Using the Console
 
 To see your validations in action, you can use the console. The console is a
-- 
cgit v1.2.3

