diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-18 17:42:03 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2015-02-18 17:42:03 -0200 |
commit | 3bd7c29acede48bffd6ff381d2ee3b68f6af2deb (patch) | |
tree | c98c9f0eaa2014818668d33fdf754500b604de51 /actionview | |
parent | 02b955766e5094c1f0afac04f415632e0463eea8 (diff) | |
parent | 3e66017b55fe2a94d3dbd50d5de8422f5724be4a (diff) | |
download | rails-3bd7c29acede48bffd6ff381d2ee3b68f6af2deb.tar.gz rails-3bd7c29acede48bffd6ff381d2ee3b68f6af2deb.tar.bz2 rails-3bd7c29acede48bffd6ff381d2ee3b68f6af2deb.zip |
Merge pull request #18970 from nithinbekal/local-assigns-doc
Add documentation for local_assigns [ci skip]
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/lib/action_view/base.rb | 8 |
1 files changed, 8 insertions, 0 deletions
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 <tt>local_assigns</tt> 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 + # <tt>defined? headline</tt> 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, |