From 3e66017b55fe2a94d3dbd50d5de8422f5724be4a Mon Sep 17 00:00:00 2001 From: Nithin Bekal Date: Tue, 17 Feb 2015 18:23:16 +0530 Subject: Add documentation for local_assigns [ci skip] --- actionview/lib/action_view/base.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/actionview/lib/action_view/base.rb b/actionview/lib/action_view/base.rb index 1feafc1094..43124bb904 100644 --- a/actionview/lib/action_view/base.rb +++ b/actionview/lib/action_view/base.rb @@ -70,6 +70,14 @@ module ActionView #:nodoc: # Headline: <%= headline %> # First name: <%= person.first_name %> # + # The local variables passed to sub templates can be accessed as a hash using the local_assigns hash. This lets you access the + # variables as: + # + # Headline: <%= local_assigns[:headline] %> + # + # This is useful in cases where you aren't sure if the local variable has been assigned. Alternately, you could also use + # defined? headline to first check if the variable has been assigned before using it. + # # === Template caching # # By default, Rails will compile each template to a method in order to render it. When you alter a template, -- cgit v1.2.3